Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

const

I have trouble to initialize a const in class,where should I initialize it ?
A sample is ideal.

It's very urgent,please hurry up.

Thanks.
0
Codemadguy
Asked:
Codemadguy
1 Solution
 
WynCommented:
You'd initialize those const variables in the constructor initializer list because const in class has different meaning versus in local or file scope.

class blah
{

const char blahwords;
public:
blah(char c='C');
}

blah::blah(char c):blahwords(c)
{
//other initializations.
}

Sincerely hope above helpful...

Regards
W.Yinan
0
 
CodemadguyAuthor Commented:
Great pal,both the speed and answer!
It works.
Thanks.



0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now