| 12
 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
 
 | ******************************
#include <iostream>
using namespace std;
 
 
class point
{ /* declaration of private members*/
private:
int x;
int y;
/*declaration of public members*/
public:
point(int,int); // constructor
void displace (int, int);
void view ();
};
 
point::point (int abs, int ord);
{
x = abs; y = ord;
}
void point::displace (int dx, int dy)
{
x+= dx; y+= dy;
}
void poin::view ()
{
cout << " I am at " << x << " " << y << "\n";
}
 
main()
{
point a(5,2);
a.view();
a.displace (-2,4); a.view();
point b(1,-1); b.view();
}
 
************************************ | 
Partager