I have two questions, what is the difference between a default/base construct and a construct initialize list?
A default constructor is a constructor that will be invoked when you create an object but don't specify any constructor arguments. For example, all these variables will be initialised by a call to the default constructor:
Complex myComplex1;
Complex myComplex2();
Complex myComplex3{};
Some other constructors do require arguments, so they're not default constructors.
In the implementation of any constructor (whether a default constructor or not) for an object with bases or member variables or constants, you can use an initialisation list to construct/initialise those bases or members.
They look the same to me, here are my examples. Do I have them commented correctly as well as what they are?
You didn't have them commented correctly. A fixed version is:
Complex::Complex() // default constructor as it does not require args
: real{}, imag{} // initialization list: sets both to 0.0
{ }
Complex::Complex(double inReal, double inImag) // NOT a default constructor
// as it requires arguments
: real(inReal), imag(inImag) // initialisation list
{
// real = inReal; // set in the initialisation list instead
// imag = inImag;
}
The non-default constructor above is invoked when you create an object while specifying matching constructor arguments:
Complex myComplex4(3.1, 2);
Complex myComplex5{-2.3, 2.7};
It's a good idea to preferentially use an initialisation list to construct your bases and set your members: otherwise at best they'll be default initialised then assigned to, which can be less efficient, but for references and constants you simply have to use an initialisation list.
It is possible to create a default constructor with arguments with default values:
Complex(double inReal = 0.0, double inImag = 0.0)
: real(inReal), imag(inImag)
{ }
This single constructor can reasonably replace both the constructors in your code.