Can you make a static constant?

  • Thread starter Thread starter Phill
  • Start date Start date
P

Phill

Something like this:

class X
{
static const int MY_CONSTANT = 10;
}

I want the variable to be constant and to be shared by all instances
of the class so as to not waste memory.
 
Phill,

You should just use the const keyword then. By default, const is
static.

Hope this helps.
 
Back
Top