Solved

const

Posted on 2000-03-21
2
251 Views
Last Modified: 2010-05-18
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
Comment
Question by:Codemadguy
2 Comments
 
LVL 5

Accepted Solution

by:
Wyn earned 280 total points
ID: 2643342
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
 

Author Comment

by:Codemadguy
ID: 2643351
Great pal,both the speed and answer!
It works.
Thanks.



0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Load and store *.pnm image file 1 77
how to understand recursion 12 219
c++ substatte a varabe for a string in a LPCTSTR statment 8 83
Arduino EDI - Programming language 3 80
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now