| 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
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 
 | #ifndef personne
#include <iostream>
#include <string>
using namespace std;
 class Personne
 {
               char *nom [20];
               char *prenom [20];
               int age;
               public:
                      Personne(int[] , int [], int );
                      Personne();
                      Personne(Personne &p);             
                      ~Personne();
 
                      void affiche();
 
};
#endif 
#include "personne.h"
#include"string.h"
using namespace std;
 Personne::Personne(char *n, char *p, int a) // contructeur
                                    {
 
                                        strcpy(nom,n);
 
 
                                        strcpy(prenom,p);
                                        age=a;
                                        cout<< "construction d'un personne"<<endl;
                                        }
  Personne::Personne( personne & p) // constructeur par recopie
           {
                    personne.nom=  p.nom ;
                    personne.prenom=p.prenom ; 
                    personne.age=p.age;   
                    }      
  Personne::Personne() // constructeur par défaut
                    {
                                        strcpy(personne.nom="");
                                        strcpy(personne.prenom="");
                                        this.age=0;
 
 Personne:: ~Personne() // destructeur
                      {
                      cout<<"destruction du personne"<<endl;
                      delete []nom;
                      delete []prenom;
                      }
  void Personne:: affiche()
                      {
                           cout<< endl<<"nom:"<<nom<<endl<<"prenom:"<<prenom<<endl<<"age:"<<age<< endl;
                           }
#include <cstdlib>
#include <iostream>
#include "personne.h"
using namespace std;
 
int main(int argc, char *argv[])
{
 
 
    Personne A();
    Personne B("yousra","skiod",21);
    A.affiche();
    B.affiche();
 
 
    system("PAUSE");
    return EXIT_SUCCESS;
} | 
Partager