Cours c++
#include <iostream>
#include <iomanip>
using namespace std;
struct point{ /* déclaration "classique" des données */
int x , y ;
/* déclaration des fonctions membres (méthodes) */
void intialise (int, int) ;
void deplace (int, int) ;
void affiche () ;
};
void point::intialise (int abs,int ord){
x= abs ;
y= ord ;
void point:: deplace (int dx, int dy){
x+=dx;
y+=dy;
void point:: affiche(){
cout<< "Je suis en " << x << " " << y << "\n" ;
/* run this program using the console pauser or add your own getch, system("pause") or input loop
*/
int main(int argc, char** argv) {
struct point p1;
[Link](5,2);
[Link]();
return 0;
Les classe :
#include <iostream>
#include <iomanip>
using namespace std;
class point {
private :
int x ;
int y ;
public :
void intialise (int, int );
void deplace (int, int);
void affiche ();
int Getx();
void Set (int val);
void Sety (int b){
y=b;
};
void point::intialise(int abs,int ord)
x=abs;
y=ord;
void point::deplace(int dx, int dy){
x=x+dx;
y=y+dy;
}
int point::Getx(){
return x;
void point::Set(int v){
x=v;
void point::affiche(){
cout << "Je suis en " << x << " " << y << "\n" ;
main (){
point a, b ;
[Link] (5, 2) ; [Link] () ;
[Link] (-2, 4) ; [Link] () ;
[Link] (1,-1) ; [Link] () ;
[Link](8);
cout<<[Link]();