Possible Duplicate:
What is this weird colon-member syntax in the constructor?
I am looking at this. What does the part after the colon mean ?
explicit Box(double l, double w, double h) : Rectangle(l, w), height(h) {}
I am used to initializing the values in the function body {}.
This is the actual way of initializing the data members. Normally constructors have two phases, namely initialization and computation.
And whatever you do inside { }, that comes under computation phase.
Even if you don’t write a initialize list in your code the compiler puts hidden code to initialize your data members. So if you write
It means you are just assigning values to which are all ready been initialized.
This type of initialization is mandatory when you have constant or reference data members in your class. Because you can’t assign values to them inside the constructor body i.e. inside { }