Use the point2D class as base class
to derive a new class called
Point3D(x,y,z). In addition to the
derived variables and functions
(methods) the new class has the
variable z with the functions setZ(z1),
getZ(), MoveRel(Dx,Dy,Dz), print(), and
the constructers point3D(),
point3D(x1,y1,z1,pColor), the destructor
-point3D(). Determine which function
is an override function and which one
is an overloaded function of the base
class.
#include <iostream>
using namespace std;
class point2D{
protected:
int x;
int y;
public:
void setX(int x) {
this->x=x;
}
void setY(int y) {
this->y=y;
}
int getX(){
return x;
}
int getY(){
return y;
}
};
class point3D:public point2D
{
private:
int z;
public:
point3D(){
}
void setZ(int z1) {
z=z1;
}
int getZ(){
return z;
}
void MoveRel(int Dx,int Dy,int Dz){
x=Dx;
y=Dy;
z=Dz;
}
void print(){
cout<<"\nx= "<<x<<endl;
cout<<"\ny= "<<y<<endl;
cout<<"\nz= "<<z<<endl;
}
point3D(int x1, int y1,int z1,string pColor){
}
~point3D(){
}
};
int main() {
return 0;
}
Comments
Leave a comment