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 60 61 62 63 64 65 66 67
| #include <iostream.h>
#include <string.h>
#include <stdlib.h>
typedef char chaine[30];
/******************* Classe personne ******************/
class personne{
private:
chaine nom, prenom, adr, CP, ville;
public:
personne();
void saisir();
void aff();
};
personne::personne(){
strset(this->nom,'\0');
strset(this->prenom,'\0');
strset(this->adr,'\0');
strset(this->CP,'\0');
strset(this->ville,'\0');
}
void personne ::saisir(){
cout <<"\n ---------- SAISIE des infos Personne -----------";
cout <<"\n -- Nom : ";
cin.ignore();
cin.getline(this->nom,30,'\n');
cout <<"\n -- Prenom : ";
cin.getline(this->prenom,30,'\n');
cout <<"\n -- Adresse : ";
cin.getline(this->adr,30,'\n');
cout <<"\n -- Code postal: ";
cin.getline(this->CP,30,'\n');
cout <<"\n -- Ville : ";
cin.getline(this->ville,30,'\n');
}
void personne ::aff(){
cout <<"\n ---------- Infos Personne -----------";
cout <<"\n -- Nom : "<<this->nom<<endl;
cout <<"\n -- Prenom : "<<this->prenom<<endl;
cout <<"\n -- Adresse : "<<this->adr<<endl;
cout <<"\n -- Code postal : "<<this->CP<<endl;
cout <<"\n -- Ville : "<<this->ville<<endl;
}
/*------------------------------------MAIN-------------------------------------*/
void main(){
personne p;
int choix;
do{
cout <<"\n ---------- infos Personne ---------------------------";
cout <<"\n -- 1 --> Saisi --";
cout <<"\n -- 2 --> Afficher --";
cout <<"\n -- 0 --> Quitter --";
cout <<"\n ---------------------------------------------------------";
cout<<"\n\n Votre choix --> ";
cin>>choix;
switch (choix){
case 1 : p.saisir(); break;
case 2 : p.aff(); break;
case 0 : cout << "\n ---------------- FIN --------------\n";break;
default : cout << "\n ---------------- Error-------------\n";break;
}
}while (choix !=0);
} |
Partager