Initializing data membersThere are two ways to initialize data members.
- Explicit assignments in a constructor.
- In a member initializer in the constructor header.
Member initializer syntaxThe definition (not the prototype) header is followed by a colon, the name of the field, and a parenthesized initial value. Separate multiple initializations with commas.
Insert example here
Member initializer required in the following cases
- To initialize
- To initialize references.
- To initialize member objects. If a member initializer is not provided, the default constructor for that class will be called.
- To initialize base class members.