Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

#include <iostream>

using namespace std;

class point

private:

int x, y;

char N;

public:

point()

x=0; y=0; N='O';

point(int a, int b, char C)

x=a;y=b;N=C;

point(const point& A)

{x=A.x ; y=A.y ; N=A.N;}

~point(){

cout<<"Au revoir";

void Afficher()

cout <<"x="<<getx()<<",";

cout <<"y="<<gety()<<",";
cout <<"N="<<getN()<<endl;

void setN(char c){

N=c;

void setx(int a){

x=a;

void sety(int b){

y=b;

char getN(){return N;}

int getx(){return x;}

int gety(){return y;}

};

int main()

point *O= new point();

point *C= new point(2,3,'C');

point *D=new point(*C);

O->Afficher();

C->Afficher();

D->setN('D');

D->setx(30);

D->sety(40);

cout<<O->getx() <<endl;
D->Afficher();

point Z(1,3,'Z');

Z.Afficher();

Exercice :

#include <iostream>

#include "point.h"

using namespace std;

class rectangle

point A=point();

point B=point();

point C=point();

point D= point();

public:

rectangle()

//point A();

//point B(1,0,'B');

//point C(1,3,'C');

//point D(0,3,'D');

B.setx(1);

B.sety(0);

B.setN('B');

C.setx(1);

C.sety(3);
C.setN('C');

D.setx(0);

D.sety(3);

D.setN('D');

void Affiche_rec()

A.Afficher();

B.Afficher();

C.Afficher();

D.Afficher();

};

int main()

rectangle R=rectangle();

R.Affiche_rec();

You might also like