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.
Code:
class 1DPoint // The base Class
{
public:
1DPoint() // No parameters
1DPoint(int x) // One parameter
int x = 0;
~point1DClass(); //Destructor function
};
class 2DPoint: public 1DPoint
{
public:
2DPoint() // No Parameter
2DPoint(int x, int y) // Two Parameters
int y = 0;
~point2DClass(); //Destructor function
};
class 3DPoint : public 2DPoint
{
public:
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 ()
{
1DPoint(4);
2DPoint(6,3);
3DPoint(2,1,7);
}
return 0;
