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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| #include <iostream.h>
class Point{
private :
float m_x,m_y;
public :
Point();
Point(float,float);
~Point();
void ModifieCoo(float,float);
void AfficheCoo() const;
void Translation(const Point,const Point);
};
Point::Point(float a,float b)
{
m_x=a;
m_y=b;
}
Point::Point()
{
m_x=0;
m_y=0;
}
Point::~Point()
{
cout<<"Point detruit"<<endl;
}
void Point::ModifieCoo(float a,float b)
{
m_x=a;
m_y=b;
}
void Point::AfficheCoo() const
{
cout<<"x="<<m_x<<" et y="<<m_y<<endl;
}
void Point::Translation(Point A,Point B)
{
this->ModifieCoo(m_x+(B.m_x-A.m_x),m_y+(B.m_y-A.m_y));
}
int main(void)
{
Point po(15,16),A(2,1),B(3,3);
po.AfficheCoo();
po.ModifieCoo(1,1);
po.AfficheCoo();
po.Translation(A,B);
po.AfficheCoo();
system("pause");
return 0;
} |
Partager