I have a class Personne which has two inheritors : Enseignant an Etudiant, another class EleveVacataire inherits these two classes. meanwile i have a method nom() which is redifined in every class but when i apply this method to an attribute EleveVacataie it gives me an error that the base Personne is imbiguous with EleveVacataie as you can see below so can anyone help me in this condition(multiple heritage):
#include<iostream>
#include<string>
using namespace std;
class Personne{
private:
string _nom;
public:
Personne(string n="EMPTY"):_nom(n){}
virtual string nom(){return _nom;}
};
class Etudiant : public Personne{
private:
string _filiere;
string _enseignement;
public:
Etudiant(string n="EMPTY",string f="EMPTY",string ens="EMPTY"):Personne(n),_filiere(f),_enseignement(ens){}
string filiere(){return _filiere;}
string enseignement(){return _enseignement;}
void setEnseignement(string ens){_enseignement=ens;}
string nom(){return "Eleve: "+Personne::nom();}
};
class Enseignant: public Personne{
private:
int _service;
public:
Enseignant(string n="EMPTY",int s=0):Personne(n),_service(s){}
int nbheure(){return _service;}
string nom(){return "Enseignent: "+Personne::nom();}
};
class EleveVacataire : public Etudiant , public Enseignant{
public:
using Etudiant::nom;
EleveVacataire(string n="EMPTY",string f="EMPTY",string ens="EMPTY",int s=0):Etudiant(n,f,ens),Enseignant(n,s){}
string nom(){
string t=Etudiant::nom();
return "Vacataire: "+t;}
};
void afficheNom(Personne & p){
cout<<p.nom()<<endl;
}
int main(){
Personne p1("Omar"),p2("Ayoub"),p3("Ismail"),p4;
Etudiant eleve("Youssef","GSEII1","POO,prog");
Enseignant prof("ARABI",24);
EleveVacataire elv("Moussa","INFO2","TEC",12);
afficheNom(p1);
afficheNom(p2);
afficheNom(p3);
afficheNom(p4);
afficheNom(eleve);
afficheNom(prof);
afficheNom(elv);
return 0;
}