Foo(int num): bar(num)
In C++, this is known as a Member Initializer List.
Simply put, it sets the value of your member bar to num.
There is a significant difference between initializing a member with the Member initializer list and assigning a value to it within the function Object() { [native code] } body.
When you use the Member initializer list to initialise fields, the constructors are only called once, and the object is constructed and initialised in a single operation.
If you use assignment, the fields will be initialised with default constructors and then reassigned with actual values (via the assignment operator).
As you can see, there is an extra overhead of creation and assignment in the latter, which may be significant for user defined classes.
Cost of Member Initialization =Object Construction
Cost of Member Assignment =Object Construction + Assignment