Constructor overloading

Discussion in 'C++' started by student19, May 7, 2011.

  1. student19

    student19 New Member

    May 7, 2011
    Likes Received:
    Trophy Points:
    I need to use function overloading to :

    Accept all co-ordinates as arguments and set data members to match.

    I don't know how to accept the co-ordinates as arguments and how to set the data members to match. Any advice would be good thanks

    I have 3 classes , class 1Dpoint class2dpoint and class3dpoint. 1dcontains data member x, 2d contains x and y and 3d contains x,y and z. I have to use multiple constructors as means of function overloading. currently i have constructors : point1d, point2d and point3d. I have already started function overloading, and i have accepted no parameters and set co-ordinates to 0 ( well i think what i have done is correct). And my next step is the one above.

    class 1DPoint    // The base Class
     1DPoint() // No parameters
     1DPoint(int x) // One parameter
        int x = 0;
        ~point1DClass();    //Destructor function
    class 2DPoint: public 1DPoint
    2DPoint() // No Parameter
    2DPoint(int x, int y) // Two Parameters
        int y = 0;
        ~point2DClass();    //Destructor function
    class 3DPoint : public 2DPoint
    3Dpoint()// No Parameter
    3DPoint(int x, int y, int z) // Three Parameters
      int z = 0;
     ~point3DClass();    //Destructor function
    point3DClass::point3DClass(int x, int y, int z)
       x = 0;
       y = 0;
       z = 0;
    int main ()
    return 0;

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice