Are the three variables following the declaration being initialized?
If so, why not to do it within the pair {} and how can they be initialized before their declaration?
That's the constructor initializer list. Its sole purpose is to initialize members.
Also, it can initialize them before their declaration because the compiler waits for the closing brace of the class before looking for members in the class. (I'm sure there's a more proper way of phrasing that, but I can't really think of one)
Just as an aside, it's important to note the difference between the initializer list and the body of the constructor.
The variables are declared the minute you create the class object, constructor or no, afaik. But if you do the "initializing" in the body of the constructor, it's actually assignment - obliteration of the previous value followed by the instantiation of a new value. The initializer list, on the other hand, initializes the variables directly. It's like the difference between
1 2 3 4
int var;
var = 10; // assignment
int var = 10; // initialization
Note what I just said. There is actually a difference, in terms of effects, between initializing in the body (curly braces) and the initializer list (following a colon).
Thank you all for the help.
tummychow,
I hadn't seen your answer when I replied. I could understand after your "int var" example =)
I also just read an article about the difference between initialization and assigment and it became clear.