Vous êtes sur la page 1sur 3

Réalisé par 

: mohammed karmoud

#include<iostream>
#include<string>
using namespace std;
//declaration de la classe mere employe
class employe {
private :
string nom;
string prenom;
int age;
public:
employe(string,string,int);
virtual float salaires ();
virtual void afficher();
~employe();

};
//declaration du constructeur

employe::employe(string n ,string p ,int a){


nom=n;
prenom=p;
age=a;
};
//methode afficher

void employe::afficher(){
cout<<"le nom est :"<<nom<<"\n";
cout<<"le prenom est :"<<prenom<<"\n";
cout<<"l'age est :"<<age<<"\n";
}
//methodes salaires vide
float employe::salaires(){
return 0;
};
//declaration du disctricteur
employe::~employe(){
};

//declaration de la classe technicien

class technicien:public employe{


int nombre_de_deplacement;
public:
technicien(string,string,int,int);
float salaires();
void afficher();
~technicien();

};
//declaration de constructeur pour technicien

technicien::technicien(string n ,string p ,int a,int nb):employe (n,p,a){


nombre_de_deplacement=nb;
}
// methodes pour calcul salaire
float technicien::salaires(){
float s;
return s=4000+(100*nombre_de_deplacement);
}
//methodes afficher
void technicien::afficher(){
employe::afficher();
cout<<"le salaire est :"<<technicien::salaires()<<"\n";
}
// le destructrue pour technicien
technicien::~technicien(){
}

//declaration de la classe technicien

class comercial:public employe{


float prime;
public:
comercial(string,string,int,float);
float salaires();
void afficher();
~comercial();
}
//declaration de constructeur pour comercial
comercial::comercial(string n ,string p ,int a,float nb):employe (n,p,a){
prime=nb;
}
// methodes pour calcul salaire
float comercial::salaires(){
float s;
return s=5000+prime;
}
//methodes afficher
void comercial::afficher(){
employe::afficher();
cout<<"le salaire est :"<<comercial::salaires()<<"\n";
}
// le destructrue pour comercial
comercial::~comercial(){
}
//fonction main
int main(){
comercial a("ali","yaya",50,1200);
a.afficher();
employe*e[4];
e[0]=new comercial("lahlali","soufiane",23,150);
e[1]=new comercial("sarragi","mehdi",29,153) ;
e[2]=new technicien("karmoud","mohammed",36,4);
e[3]=new technicien("kabil","khalil",38,5) ;
e[0]->afficher();
e[1]->afficher();
e[2]->afficher();
e[3]->afficher();
float s=0;
int i;
for(i=0;i<=3;i++){
s=s+e[i]->salaires();
}
cout<<"le salaire totale est :"<<s<<endl;
return 0 ;
}

Vous aimerez peut-être aussi