Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   what does ":" do in c++ code? (http://www.go4expert.com/forums/cpp-code-t6560/)

asilter 27Sep2007 14:25

what does ":" do in c++ code?
 
i'm trying to read and understand a .cc (c++)file,
i want to know what does ok_flag(false),time_range(false),prefix() do after ":" ?
I did know that ":" was being used for class inheritance but what is ":" for in the bleow code?
Code:

ClassA::ClassA(const char *db) : ok_flag(false),time_range(false),prefix()
{
//.. Constructor statements
}

plz help
thanx.

DaWei 27Sep2007 17:02

Re: what does ":" do in c++ code?
 
It initializes those variables in the class. It's more effective than putting statements inside the constructor.

shabbir 27Sep2007 17:16

Re: what does ":" do in c++ code?
 
As far as I can remember its called initialization block.

asilter 27Sep2007 18:55

Re: what does ":" do in c++ code?
 
ok,thanks.


All times are GMT +5.5. The time now is 14:22.