A single colon in this context is used to signal that you are using an initializer list. An initializer list is used to:
- Invoke base class constructors from a derived class
- Initialize member variables of the class
As noted by others, an initializer list can only be used on a class constructor.
While it's also possible to initialize member variables in the body of the constructor, there are several reasons for doing so via the initializer list:
- Constant pointers or references cannot be initialized from the body of the constructor
- It is usually more efficient to use the initializer list as it will (from memory) only invoke the constructor for the member, rather than the constructor and assignment operator which can be costly for non-POD types.
Having said all of this, the formatting of your code is a bit odd. In the code that I usually work with, use of an initializer list would be indented like this:
A::A()
:b(),
c()
{
}
This makes it more clear to me that the :
has no relation to the ::
used to define class membership in A::A()
.