Solved

const

Posted on 2000-03-21
2
250 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

707 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

12 Experts available now in Live!

Get 1:1 Help Now