Correction examen c++

Fermé
Majestick Messages postés 19 Date d'inscription jeudi 26 février 2015 Statut Membre Dernière intervention 2 octobre 2015 - Modifié par Majestick le 26/02/2015 à 13:44
Whismeril Messages postés 19029 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 26 avril 2024 - 26 févr. 2015 à 14:45
Bonjour,
Je vous contacte car j'ai un examen en C++ (à l'écrit) vendredi. J'ai une annale à laquelle j'ai répondu et je souhaiterais savoir si vous pourriez jeter un coup d'oeil aux réponses que j'ai apporté.
Je vous joins l'annale et mes réponses:



Et voici mon code:
Client.h
#ifndef __annale2014__client__
#define __annale2014__client__

//#include "agenceLocale.h"
#include <iostream>
#include <string>

using namespace std;
class Client {
 string nom;
 string adresse;
 AgenceLocale& agenceLocale;

 public:
  Client(string n="", string a="", AgenceLocale& al);

  AgenceLocale operator();
  void afficher();
};
#endif /* defined(__annale2014__client__) */


Client.cpp

#include "client.h"

Client(string n,string a, AgenceLocale& al):this->nom(n), this->adresse(a), this->agenceLocale(al){}
AgenceLocale operator() {return this->agenceLocale->nom;}
void afficher() {cout << this->nom << this->adresse << this->*agenceLocale;}



Employe.h

#ifndef __annale2014__employe__
#define __annale2014__employe__

#include "agenceLocale.h"
#include <iostream>
#include <string>

using namespace std;

class Employe {
 string nom;
 int id;
 AgenceLocale *agl;

 public:
  Employe(string n="", int i = 0);
  virtual void afficher();
  virtual float calculerSalaire() = 0;
};
#endif /* defined(__annale2014__employe__) */



Employe.cpp

#include "employe.h"

Employe(string n, int i):this->nom(n), this->id(i) {}
virtual void afficher() {cout << this->nom << this->id << this->*agl;}
virtual float calculerSalaire() = 0;




Commercial.h

#ifndef __annale2014__commercial__
#define __annale2014__commercial__

#include <iostream>
#include <string>

using namespace std;
class Commercial:public Employe {
 float pourcentage;
 float fixe;

 public:
  Commercial(string n="", int i =0, float p=0.0, float f=0.0);
  public float calculerSalaire();
}
#endif /* defined(__annale2014__commercial__) */



Commercial.cpp

#include "commercial.h"

Commercial(string n, int i =0, float p=0.0, float f=0.0):Employer(n,i), pourcentage(p), fixe(f) {}
float calculerSalaire(){}



AgenceLocale.h

#ifndef __annale2014__agenceLocale__
#define __annale2014__agenceLocale__

#include "region.h"
#include "employe.h"
#include "client.h"
#include "vente.h"
#include <iostream>
#include <string>
#include <list>

using namespace std;
class AgenceLocale {
 string nom;
 Region& nomR;
 int nbEmp;
 Employe employe[nbEmp];
 list<Client> c;
 list<Vente> v;

 public:
  AgenceLocale(string n="", Region& r, int nb = 0);
  AgenceLocale(const AgenceLocale& copie);

  void addEmploye(string nom, int id);
  Vente AgenceLocale::operator[](int i);
  ostream& operator<<(ostream& out, Client& c);
  float calculerSalaire();
  float  salaireCommerciaux();
};
#endif /* defined(__annale2014__agenceLocale__) */



AgenceLocale.cpp

#include "agenceLocale.h"

AgenceLocale(string n, Region& r, int nb):this->nom(n), this->nomR(r), this->nbEmp(nb) {
    employe = new Employe[nb];
    c = *new list<Client>();
    v = *new list<Vente>();
}

AgenceLocale(const AgenceLocale& copie) {
    this->nom = copie.nom;
    this->nomR = copie.nomR;
    this->nbEmp = copie.nbEmp;
    this->employe = copie.employe;
    this->employe = new Employe[copie.nbEmp];
    for(int i = 0; i < nbEmp; i++) {
        this->employe[i] = copie.employe[i];
    }
    c = copie.c;
    v = copie.v;
}

void addEmploye(string nom, int id) {
    Employe * e = new Employe(nom, id);
    this->employe[nbEmp] = *e;
    this->nbEmp++;
}

Vente AgenceLocale::operator[](int i) const {
    return v[i];
}

ostream& operator<<(ostream& out, Client& c) {
    for(list<Clien*> ::iterator it=lclient.begin(); it != lclient.endl();++it) {
        out << it->c.nom << endl;
    }
}

float calculerSalaire() {
    list<Employe> lemploye;
    float somme = 0.0;
    for(list<Employe*>::iterator it = lemploye.begin(); it != lemploye.end();++it) {
        somme += it->calculerSalaire();
    }
    return somme;
}

float salaireCommerciaux() {
    list<Commercial> lcommercial;
    float somme = 0.0;
    for(list<Commercial*>::iterator it = lcommercial.begin(); it != lcommercial.end();++it) {
        somme += it->calculerSalaire();
    }
    return somme;
}



J'espère que vous pourrez m'indiquer où je me suis trompé et pourquoi.
Je vous remercie de votre aide!

1 réponse

Whismeril Messages postés 19029 Date d'inscription mardi 11 mars 2003 Statut Contributeur Dernière intervention 26 avril 2024 931
26 févr. 2015 à 14:45
0