I came across this info after searching for a way to get a few wxWidgets classes to initialize properly when put as a member of another class or when I needed to expand the functionality of a wxWidgets class. Since wxWidgets is what I call "aggressively OOP," many of its classes do not have a default constructor, and require a initialization list to work correctly. This is the article that finally shed light on how initialization lists work :
http://www.cprogramming.com/tutorial/initialization-lists-c++.htmlAs a writing exercise, I wrote up a few paragraphs in my own words. It's been a long time since I last made a tutorial, so please forgive me if things seem a bit out of whack.

--Z
Did you ever wonder why classes have to have their own constructors, even when they inherit at least one other class or structure? The truth is that child classes first call their parent class's before going into their own constructor, essentially meaning that the child classes "tack on" whatever methods and members they have into an instance of their parent class.
If a child class has multiple parents, then the parents' constructors are called in the sequence that they are listed. Also, if the parent class is itself a child or derived class, then the parent classes are called in sequence from the base class down.
This mechanism is usually done by the C++ compiler, and the programmer does not have to worry if all of the parent classes have their own default constructor. However, if any of the parent classes do NOT have a default constructor, then the programmer must intervene and tell the compiler which constructor to use.
This is done via an initialization list:
// Header file
class parent
{
public:
parent( int a ); // Non-default Constructor specified. Compiler won't make a default constructor.
private:
int parent_var;
};
class child : public parent
{
public:
child( int b )
private:
int child_var;
};
// Implementation File
parent::parent( int a )
{
parent_var = a;
}
child::child( int b )
: parent( 0 )
{
child_var = b;
}
The " : parent( 0 )" is what is called an
initialization list. This list specifies which constructors to call before the child constructor is even entered. Going back to our example, when an instance of the child class is made, it will have a parent_var with a value of 0 and a child_var with the value of b. However, since parent_var is specified as a private member of the parent class, it is not accessible by any methods in the child class or any other derived. As a reminder, protected methods and members are accessible by any methods in any methods inside the parent class and any of the child classes.
The initialization list is also handy for calling constructors of classes that are member of the class that is being constructed. For example:
// Header file
class Kung
{
public:
Kung( int a );
private:
int kung_var;
}
class Bar
{
public:
Bar( int b );
private:
Kung foo;
int bar_var;
}
// Implementation file
Kung::Kung( int a )
{
kung_var = a;
}
Bar::Bar( int b )
: foo( b ) // Note: this isn't the name of the class type, this is the name of the member
{
}
Which ends up with the kung_var with whatever value b has.
As a closing note, the initialization list can also initialize members that are standard types along with the constructors:
// foo's constructor is called, and then bar_var is set to 42;
Bar::Bar( int b )
: foo( b ), bar_var( 42 ) // By convention, the members are initialized in the same order they are specified.
// Some compilers allow you to specify them in any order, but remember that they are initialized in order they show up here!
{
}