Use the aggregation (composition)
concept to define and implement the
class line(pl.x, pl.y, p2.x, p2.y) by using
two points variables P 1, and P2 of type
point2D class defined in QI. Beside the
two points Pl and P2, the line class has
the following functions: print(),
MoveRel(Dx,Dy) (use the point2D's
MoveRel(Dx,Dy) function of the two
points to achieve that), line(),
class line{
private:
point2D p1;
point2D p2;
public:
void print(){
cout<<"P1= "<<p1;
cout<<"P2= "<<p2;
}
void MoveRel(point2D Dx, point2D Dy){
p1=Dx;
p2=Dy;
}
line(){
}
};
Comments
Leave a comment