<<<Index>>>

The initializer list

    // point.h
    class Point
    {
    private:
        Graph& m_g;
        int    m_x;
        int    m_y;
    public:
        Point( Graph& g, int x, int y );
    };
  • New syntax for constructors:

        // point.cpp
        Point::Point( Graph& g, int x, int y )
        :   m_g( g )
        {
            m_x = x;
            m_y = y;
        }
  • or,

       // point.cpp
        Point::Point( Graph& g, int x, int y )
        :   m_g( g ),
            m_x( x ),
            m_y( y )
        {
        }
<<<Index>>>