1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
class poly
{
public:
poly (const poly& rhs); ///define this copy constructor
poly (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, )
:x_1(x_1),y_1(y_1),x_2(x_2),y_2(y_2),x_3(x_3),y_3(y_3),x_4(x_4),y_4(y_4){}
private:
int x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4;
};
class Room: public poly
{
public:
Room (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
Room(const Room& rhs);
private:
pair<int, int> center;
int distance;
};
poly::poly (const poly& rhs)
{
///if (rhs and this are same dont do nothing
///else copy it content to this.
}
Room::Room(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
:poly (x1, y1, x2, y2, x3, y3, x4,y4)/// explicit intializer to base class
{
center.first = min(x1, x4); ///
center.second = min(y1, y2);
distance = 0;
}
Room::Room(const Room & rhs) : poly (rhs)/// rhs is a poly and a Room to , I explicitly intialize
{ /// poly members with those in rhs then my extra Room
/// variables
center.first = min(rhs.x1, rhs.x4); ///access x1 and x4 using getters. ..error! !!!
center.second = min(rhs.y1, rhs.y2);
distance = 0;
}
|