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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top