However if you use : ::
The first colon : is a indication that what will follow is an initializer list. This can appear in a class's constructor as a way to give that class's data members an initial value before the body of the constructor executes.
A small example
- Code: Select all
class Foo {
public:
Foo() :
x(3), // int initialized to 3
str("Hey!"), // std::string initialized to be the string, "Hey!"
list(5) // std::vector<float> initialized with 5 values
{ /* constructor body */ }
private:
int x;
std::string str;
std::vector<float> list;
};
-- Mon Jan 28, 2013 8:53 pm --
I highly suggest just to learn the language, I think you may end up confusing yourself...


