Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as C++ by registered user raphael ( 1 year ago )
#include <iostream>
#include <string>
#include "nomfille.h"
using namespace std;
int main()
{
cout<<"Instanciation de la classe fille :"<<endl;
NomFille obj(15,"Diane","Du chessee", 50);
cout<<obj.NomMere::toString()<<endl;
cout<<obj.toString()<<endl;
obj.setEntier_private(50);
cout<<obj.toString()<<endl;
return 0;
}
//----------------------------------------------------------------------------------------
#ifndef NOMFILLE_H
#define NOMFILLE_H
#include "nommere.h"
#include <string>
using namespace std;
class NomFille : public NomMere
{
public:
NomFille(int , string , string , int);
int depot_bancaire;
int entier_public;
void setEntier_private(int);
int getEntier_private();
string toString();
private:
int entier_prive;
};
#endif // NOMFILLE_H
//----------------------------------------------------------------------------------------
#ifndef NOMMERE_H
#define NOMMERE_H
#include <string>
using namespace std;
class NomMere
{
public:
int age;
string prenom;
string nom;
NomMere(int,string,string);
string toString();
};
#endif // NOMMERE_H
//----------------------------------------------------------------------------------------
#include "nomfille.h"
#include <iostream>
#include <string>
using namespace std;
NomFille::NomFille(int a, string p, string n, int argent) : NomMere(a,p,n)
{
cout<<"Je suis dans le constructeur de la classe fille"<<endl;
this->depot_bancaire=argent;
this->entier_public=1;
this->entier_prive=2;
}
void NomFille::setEntier_private(int x){
this->entier_prive = x;
cout<<"l'entier privé de la classe a été modifié"<<endl;
}
int NomFille::getEntier_private(){
return this->entier_prive;
}
string NomFille::toString(){
cout<<"Entier public vaut : "<<this->entier_public<<endl;
cout<<"Entier prive vaut : "<<this->entier_prive<<endl;
}
//----------------------------------------------------------------------------------------
#include "nommere.h"
#include <string>
#include <iostream>
using namespace std;
NomMere::NomMere(int a, string p, string n)
{
cout<<"Je suis dans le constructeur de la classe mere"<<endl;
this->age=a;
this->nom=n;
this->prenom=p;
}
string NomMere::toString(){
string result="";
result += nom +" "+prenom+" ";
return result;
}
Revise this Paste