Bonjour,
J'essaie de faire un programme en c++ qui affiche les commerciaux et les manutentionnaires avec leur salaire mais la console n'affiche rien, je ne sais si c'est un problème d'en tête car code blocks le compile.
Voici les fichiers
Employe.cpp
employe.hCode:
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 #include <string> #include <cstdio> #include <iostream> #include "Employe.h" using namespace std; Employe::Employe(char *n, char *p, int a) { strcpy(nom,n); strcpy(prenom,p); age=a; } Employe::~Employe(void) { } void Employe::Afficher() { cout<<"Nom : "<<nom<<endl; cout<<"Prenom : "<<prenom<<endl; cout<<"Age : "<<age<<endl; }
personnel.cppCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #pragma once using namespace std; class Employe { protected: char nom[20],prenom[20]; int age; public: Employe(char *n="", char *p="", int a=0); virtual ~Employe(void); virtual void Afficher(); virtual int CalculSalaire()=0; };
personnel.hCode:
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 #include <iostream> #include <cstdio> #include <string> #include "Personnel.h" Personnel::Personnel(int a=0) { nele=0; nmax=a; T = new Employe * [a]; } Personnel::~Personnel(void) { if(T) delete [] T; } void Personnel::Ajouter(Employe & E) { if(nele<nmax) T[nele++]=&E; } void Personnel::Affiche_Salaires() { for(int i=0;i<nele;i++) { T[i]->Afficher(); cout<<"Salaire : "<<T[i]->CalculSalaire()<<endl<<endl; } } int Personnel::Salaire_Moyen() { int moy=0; for(int i=0;i<nele;i++) moy+=T[i]->CalculSalaire(); moy/=nele; return moy; }
commercial.cppCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #pragma once #include "Manutentionnaire.h" #include "Commercial.h" class Personnel { protected: Employe ** T; int nele, nmax; public: Personnel(int); ~Personnel(void); void Ajouter(Employe &); void Affiche_Salaires(); int Salaire_Moyen(); };
commercial.hCode:
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 #include <iostream> #include <cstdio> #include <string> #include "Commercial.h" Commercial::Commercial(char *n, char *p, int a, int ca):Employe(n,p,a) { ChiffreAffaire=ca; } Commercial::~Commercial(void) { } void Commercial::Afficher() { Employe::Afficher(); cout<<"Chiffre d'affaire : "<<ChiffreAffaire<<endl; } int Commercial::CalculSalaire() { return 0.2*ChiffreAffaire+400; }
manutentionnaire.cppCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 #pragma once #include "Employe.h" class Commercial : public Employe { protected: int ChiffreAffaire; public: Commercial(char *n="", char *p="", int a=0, int ca=0); ~Commercial(void); virtual void Afficher(); virtual int CalculSalaire(); };
Manutentionnaire.hCode:
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 #include <cstdio> #include <iostream> #include <string> #include "Manutentionnaire.h" using namespace std; Manutentionnaire::Manutentionnaire(char *n, char *p, int a, int nh):Employe(n,p,a) { NombreHeures=nh; } Manutentionnaire::~Manutentionnaire(void) { } void Manutentionnaire::Afficher() { Employe::Afficher(); cout<<"Nombre d'heures : "<<NombreHeures<<endl; } int Manutentionnaire::CalculSalaire() { return 9*NombreHeures; }
prjpersonnel.cppCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 #pragma once #include "Employe.h" class Manutentionnaire : public Employe { protected: int NombreHeures; public: Manutentionnaire(char *n, char *p, int a, int nh); ~Manutentionnaire(void); virtual void Afficher(); virtual int CalculSalaire(); };
qui est le point d'entrée pour l'appli console
je ma casse la tête dessus depuis un moment, mais les corrections que j'ai pu apporter n'ont rien donné!Code:
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 #include <iostream> #include <string> #include <cstdio> #include "Personnel.h" int main(int argc, char *argv[]) { Commercial d("DUPONT","Michel",31,10235); //d.Afficher(); Commercial b("BLANC","Pierre",29,8500); Commercial d1("DUMIER","Jean",33,15600); Commercial k("KOLOSKY","Jean",29,12006); Manutentionnaire m("MANGEOT","Nicolas",35,200); Manutentionnaire u("UGUR","Mehmet",24,140); Manutentionnaire t("TURCAN","Gregory",28,148); Manutentionnaire l("LOISEAU","Henri",33,150); Manutentionnaire m1("MORIOT","Frederic",28,145); Manutentionnaire i("ISSIAR","DIA",30,178); Personnel p(10); p.Ajouter(d); p.Ajouter(b); p.Ajouter(d1); p.Ajouter(k); p.Ajouter(m); p.Ajouter(u); p.Ajouter(t); p.Ajouter(l); p.Ajouter(m1); p.Ajouter(i); p.Affiche_Salaires(); cout<<"Salaire moyen : "<<p.Salaire_Moyen()<<endl; system("PAUSE"); return 0; }
Process terminated with status -1073741510 (0 minutes, 4 seconds), compilé sous code blocks!
Merci