Table of Contents

Basic constructor

class Example
{
   public:
      void someMethod( double someDouble );
      double someFunction( void );
      Example();  // This is the constructor
 
   private:
      double someDouble;
};

Example::Example(void)
{
    cout << "Constructor was called" << endl;
}

Initialization lists to initialize members

Example::Example( double someDoubleParam): someDouble(someDoubleParam)
{
       cout << "Constructor was called" << endl;
}

Create objects

int x(5); // (int x = 5)
Fraction fiveThirds(5, 3); // Fraction fiveThirds = Fraction(5,3)