Bonsoir,
Voila mon code lors de la compilation plante à l'édition de lien sur ma classe Dico. Seulement je n'arrive pas à voir pourquoi
Voila le code de mes classes:
Dico.h
Dico.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 /*********************************************************************** * Module: Dico.h * Author: scary * Modified: mardi 30 mars 2010 11:26:00 * Purpose: Declaration of the class Dico ***********************************************************************/ #ifndef DICO_H #define DICO_H #include "Assoc.h" template<typename TypeCle, typename TypeValeur> class Dico { private : Assoc<TypeCle, TypeValeur> *tabAssoc; int nbAssoc; int tailleT; static TypeCle cleDefaut; static TypeValeur valeurDefaut; void CherchCl (const TypeCle& cl, int& i, int& res) const; public : Dico (); Dico (const Dico& dico); virtual ~Dico (); void put (const TypeCle& c, const TypeValeur& v); TypeValeur get (const TypeCle& c) const; bool estVide () const; int taille () const; bool contient (const TypeCle& cle) const; void affiche (std::ostream& os) const; void supprime (const TypeCle& cle); static int hash (TypeCle s, int tailleTab); virtual Dico& operator=(const Dico& dico); }; template <typename TypeCle, typename TypeValeur> std::ostream& operator<<(std::ostream& os, const Dico<TypeCle, TypeValeur>& dico) { dico.affiche (os); return os; } #endif
Assoc.h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246 /*********************************************************************** * Module: Dico.cpp * Author: scary * Modified: mardi 30 mars 2010 14:47:42 * Purpose: Implementation of the class Dico ***********************************************************************/ #include "Dico.h" template<typename TypeCle, typename TypeValeur> void Dico<TypeCle, TypeValeur>::CherchCl (const TypeCle& cl, int& i, int& res) const { int j = hash (cl, tailleT); i = j; res = 0; while (this->tabAssoc[i].getCle () != this->cleDefaut && this->tabAssoc[i].getCle () != cl && res != 2) { i++; if (i == tailleT) { i = 0; } if (i == j) { res = 2; } } if (this->tabAssoc[i].getCle () == cl) { res = 1; } } template<typename TypeCle, typename TypeValeur> Dico<TypeCle, TypeValeur>::Dico () { this->tabAssoc = new Assoc<TypeCle, TypeValeur>[10]; for (int i=0;i<10;i++) { this->tabAssoc[i].setCle (this->cleDefaut); this->tabAssoc[i].setValeur (this->valeurDefaut); } this->nbAssoc = 0; this->tailleT = 10; } template<typename TypeCle, typename TypeValeur> Dico<TypeCle, TypeValeur>::Dico (const Dico<TypeCle, TypeValeur> & dico) { this->tailleT = dico.tailleT; this->nbAssoc = dico.nbAssoc; this->tabAssoc = new Assoc<TypeCle, TypeValeur>[tailleT]; for(int i=0;i<this->tailleT;i++) { this->tabAssoc[i] = dico.tabAssoc[i]; } } template<typename TypeCle, typename TypeValeur> Dico<TypeCle, TypeValeur>::~Dico () { delete[] this->tabAssoc; } template<typename TypeCle, typename TypeValeur> void Dico<TypeCle,TypeValeur>::put (const TypeCle& c, const TypeValeur& v) { int i; int res; CherchCl (c, i, res); switch (res) { case 0: { this->tabAssoc[i].setCle (c); this->tabAssoc[i].setValeur (v); this->nbAssoc++; } break; case 1: { this->tabAssoc[i].setValeur (v); } break; case 2: { Dico<TypeCle, TypeValeur> dico (*this); delete[] tabAssoc; this->tailleT = dico.tailleT + 5; this->nbAssoc = 0; this->tabAssoc = new Assoc<TypeCle, TypeValeur>[tailleT]; for (int j=0;j<this->tailleT;j++) { this->tabAssoc[j].setCle (this->cleDefaut); this->tabAssoc[j].setValeur (this->valeurDefaut); } for (int j=0;j<dico.tailleT;j++) { CherchCl (dico.tabAssoc[j].getCle (), i, res); this->tabAssoc[i].setCle (dico.tabAssoc[j].getCle ()); this->tabAssoc[i].setValeur (dico.tabAssoc[j].getValeur ()); this->nbAssoc++; } CherchCl (c, i, res); this->tabAssoc[i].setCle (c); this->tabAssoc[i].setValeur (v); this->nbAssoc++; } break; } } template<typename TypeCle, typename TypeValeur> TypeValeur Dico<TypeCle, TypeValeur>::get (const TypeCle & c) const { int i; int res; CherchCl (c, i, res); if (res == 1) { return this->tabAssoc[i].getValeur (); } else { return this->valeurDefaut; } } template<typename TypeCle, typename TypeValeur> bool Dico<TypeCle,TypeValeur>::estVide () const { return this->nbAssoc == 0; } template<typename TypeCle, typename TypeValeur> bool Dico<TypeCle, TypeValeur>::contient (const TypeCle& cle) const { int i; int res; CherchCl (cle, i, res); return res == 1; } template<typename TypeCle, typename TypeValeur> int Dico<TypeCle, TypeValeur>::taille () const { return this->nbAssoc; } template <typename TypeCle, typename TypeValeur> void Dico<TypeCle, TypeValeur>::affiche (std::ostream& os) const { if (this->estVide ()) { std::cout << "Dico vide" << std::endl; } else { std::cout << "Dico" << std::endl; for (int i=0;i<this->tailleT;i++) { if (this->tabAssoc[i].getCle () != this->cleDefaut) { os << this->tabAssoc[i].getCle () << "->" << this->tabAssoc[i].getValeur () << std::endl; } } } } template <typename TypeCle, typename TypeValeur> void Dico<TypeCle, TypeValeur>::supprime (const TypeCle& cle) { if (this->contient (cle)) { for (int i=0;i<this->tailleT;i++) { if (this->tabAssoc[i].getCle () == cle) { } } } else { } } template<typename TypeCle, typename TypeValeur> Dico<TypeCle, TypeValeur>& Dico<TypeCle,TypeValeur>::operator=(const Dico<TypeCle, TypeValeur>& dico) { if (this != &dico) { delete[] tabAssoc; this->tailleT = dico.tailleT; this->nbAssoc = dico.nbAssoc; this->tabAssoc = new Assoc<TypeCle, TypeValeur>[tailleT]; for(int i=0;i<this->tailleT;i++) { this->tabAssoc[i] = dico.tabAssoc[i]; } } return *this; } template<> int Dico<std::string, int>::hash (std::string s, int tailleTab) { int i = 0; for (size_t j=0;j<s.length ();j++) { i += (j + 1) * s[j]; } return i % tailleTab; } template<> std::string Dico<std::string, int>::cleDefaut = "rien"; template<> int Dico<std::string, int>::valeurDefaut = 0; template class Dico<std::string, int>; template std::ostream& operator<<(std::ostream&, const Dico<std::string, int>&);
Assoc.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 /*********************************************************************** * Module: Assoc.h * Author: scary * Modified: mardi 30 mars 2010 11:26:00 * Purpose: Declaration of the class Assoc ***********************************************************************/ #ifndef ASSOC_H #define ASSOC_H #include <iostream> #include <string> template<typename TypeCle, typename TypeValeur> class Assoc { private: TypeCle cle; TypeValeur valeur; public: Assoc (); Assoc (TypeCle, TypeValeur); virtual ~Assoc (); virtual TypeCle getCle () const; virtual void setCle (TypeCle); virtual TypeValeur getValeur () const; virtual void setValeur (TypeValeur); virtual void affiche (std::ostream&) const; }; template<typename TypeCle, typename TypeValeur> std::ostream& operator<<(std::ostream&, const Assoc<TypeCle,TypeValeur>&); #endif
Conference.h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
50
51
52
53
54
55
56
57
58
59
60
61
62 #include "Assoc.h" template<typename TypeCle, typename TypeValeur> Assoc<TypeCle,TypeValeur>::Assoc () { } template<typename TypeCle, typename TypeValeur> Assoc<TypeCle,TypeValeur>::Assoc (TypeCle cle, TypeValeur valeur) { this->cle = cle; this->valeur = valeur; } template<typename TypeCle, typename TypeValeur> Assoc<TypeCle,TypeValeur>::~Assoc () { } template<typename TypeCle, typename TypeValeur> TypeCle Assoc<TypeCle,TypeValeur>::getCle ()const { return this->cle; } template<typename TypeCle, typename TypeValeur> void Assoc<TypeCle,TypeValeur>::setCle (TypeCle cle) { this->cle = cle; } template<typename TypeCle, typename TypeValeur> TypeValeur Assoc<TypeCle,TypeValeur>::getValeur () const { return this->valeur; } template<typename TypeCle, typename TypeValeur> void Assoc<TypeCle,TypeValeur>::setValeur (TypeValeur valeur) { this->valeur = valeur; } template<typename TypeCle, typename TypeValeur> void Assoc<TypeCle,TypeValeur>::affiche (std::ostream &os) const { os << this->getCle () << ", " << this->getValeur (); } template<typename TypeCle, typename TypeValeur> std::ostream& operator<<(std::ostream& os, const Assoc<TypeCle,TypeValeur>& assoc) { assoc.affiche (os); return os; } template class Assoc<std::string, int>; template std::ostream& operator<<(std::ostream&, const Assoc<std::string, int>&);
Conference.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
50
51
52
53
54
55
56
57
58
59
60
61 /*********************************************************************** * Module: Conference.h * Author: scary * Modified: mardi 30 mars 2010 11:26:00 * Purpose: Declaration of the class Conference ***********************************************************************/ #ifndef CONFERENCE_H #define CONFERENCE_H #include "Dico.h" #include "Papier.h" #include <vector> #include <map> class Conference { private: int budget; std::string nom; std::string lienWeb; std::vector<std::string> listeThemes; int etatCompte; int referenceCompte; Dico<Papier, std::string> papierAccepte; Dico<std::string, std::string> infoMembreComite; std::map<std::string, int> paiement; public: Conference (); Conference (int budget, std::string nom, std::string lienWeb, const std::vector<std::string>& listeThemes, int etatCompte, int referenceCompte, const Dico<Papier, std::string>& papierAccepte, const Dico<std::string, std::string>& infoMembreComite, const std::map<std::string, int>& paiement); Conference (const Conference& oldConference); ~Conference (); virtual int getBudget (void) const; virtual std::string getNom (void) const; virtual std::string getLienWeb (void) const; virtual std::vector<std::string> getListeThemes (void) const; virtual int getEtatCompte (void) const; virtual int getReferenceCompte (void) const; virtual Dico<Papier, std::string> getPapierAccepte (void) const; virtual Dico<std::string, std::string> getInfoMembreComite (void) const; virtual std::map<std::string,int> getPaiement (void) const; virtual void setBudget (int newBudget); virtual void setNom (std::string newNom); virtual void setLienWeb (std::string newLienWeb); virtual void setListeThemes (const std::vector<std::string>& newListeThemes); virtual void setEtatCompte (int newEtatCompte); virtual void setReferenceCompte (int newReferenceCompte); virtual void setPapierAccepte (const Dico<Papier, std::string>& newPapierAccepte); virtual void setInfoMembreComite (const Dico<std::string, std::string>& newInfoMembreComite); virtual void setPaiement (const std::map<std::string, int>& newPaiement); void ajoutPapier (const Papier& nouveau, std::string mailAuteur); void supprimerPapier (const Papier& ancien); virtual void saisieComite (void); virtual void affichageMontantPayer (std::ostream& os) const; virtual Conference& operator=(const Conference& c); }; #endif
Papier.h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338 /*********************************************************************** * Module: Conference.cpp * Author: scary * Modified: mardi 30 mars 2010 11:26:00 * Purpose: Implementation of the class Conference ***********************************************************************/ #include "Conference.h" //////////////////////////////////////////////////////////////////////// // Name: Conference::Conference () // Purpose: Implementation of Conference::Conference () //////////////////////////////////////////////////////////////////////// Conference::Conference () { this->budget = 0; this->nom = ""; this->lienWeb = ""; this->etatCompte = 0; this->referenceCompte = 0; } //////////////////////////////////////////////////////////////////////// // Name: Conference::Conference (int budget, std::string nom, std::string lienWeb, const std::vector<std::string>& listeThemes, int etatCompte, int referenceCompte, const Dico<Papier, std::string>& papierAccepte, const std::multimap<RoleMembre::Role, std::string>& responsabilite, const Dico<std::string, std::string>& infoMembreComite, const std::map<std::string, int>& paiement, const std::vector<ParticipationComiteProgramme>& comiteProgramme, const std::vector<ParticipationComiteOrganisation>& comiteOrganisation) // Purpose: Implementation of Conference::Conference () // Parameters: // - budget // - nom // - lienWeb // - listeThemes // - etatCompte // - referenceCompte // - papierAccepte // - responsabilite // - infoMembreComite // - paiement // - comiteProgramme // - comiteOrganisation //////////////////////////////////////////////////////////////////////// Conference::Conference (int budget, std::string nom, std::string lienWeb, const std::vector<std::string>& listeThemes, int etatCompte, int referenceCompte, const Dico<Papier, std::string>& papierAccepte, const Dico<std::string, std::string>& infoMembreComite, const std::map<std::string, int>& paiement) { this->budget = budget; this->nom = nom; this->lienWeb = lienWeb; this->etatCompte = etatCompte; this->referenceCompte = referenceCompte; this->papierAccepte = papierAccepte; this->infoMembreComite = infoMembreComite; this->paiement = paiement; } //////////////////////////////////////////////////////////////////////// // Name: Conference::Conference (const Conference& oldConference) // Purpose: Implementation of Conference::Conference () // Parameters: // - oldConference //////////////////////////////////////////////////////////////////////// Conference::Conference (const Conference& oldConference) { *this = oldConference; } //////////////////////////////////////////////////////////////////////// // Name: Conference::~Conference () // Purpose: Implementation of Conference::~Conference () //////////////////////////////////////////////////////////////////////// Conference::~Conference () { } //////////////////////////////////////////////////////////////////////// // Name: Conference::getBudget () // Purpose: Implementation of Conference::getBudget () // Return: int //////////////////////////////////////////////////////////////////////// int Conference::getBudget (void) const { return this->budget; } //////////////////////////////////////////////////////////////////////// // Name: Conference::getNom () // Purpose: Implementation of Conference::getNom () // Return: std::string //////////////////////////////////////////////////////////////////////// std::string Conference::getNom (void) const { return this->nom; } //////////////////////////////////////////////////////////////////////// // Name: Conference::getLienWeb () // Purpose: Implementation of Conference::getLienWeb () // Return: std::string //////////////////////////////////////////////////////////////////////// std::string Conference::getLienWeb (void) const { return this->lienWeb; } //////////////////////////////////////////////////////////////////////// // Name: Conference::getListeThemes () // Purpose: Implementation of Conference::getListeThemes () // Return: std::vector<std::string> //////////////////////////////////////////////////////////////////////// std::vector<std::string> Conference::getListeThemes (void) const { return this->listeThemes; } //////////////////////////////////////////////////////////////////////// // Name: Conference::getEtatCompte () // Purpose: Implementation of Conference::getEtatCompte () // Return: int //////////////////////////////////////////////////////////////////////// int Conference::getEtatCompte (void) const { return this->etatCompte; } //////////////////////////////////////////////////////////////////////// // Name: Conference::getReferenceCompte () // Purpose: Implementation of Conference::getReferenceCompte () // Return: int //////////////////////////////////////////////////////////////////////// int Conference::getReferenceCompte (void) const { return this->referenceCompte; } //////////////////////////////////////////////////////////////////////// // Name: Conference::getPapierAccepte () // Purpose: Implementation of Conference::getPapierAccepte () // Return: Dico<Papier, std::string> //////////////////////////////////////////////////////////////////////// Dico<Papier, std::string> Conference::getPapierAccepte (void) const { return this->papierAccepte; } //////////////////////////////////////////////////////////////////////// // Name: Conference::getInfoMembreComite () // Purpose: Implementation of Conference::getInfoMembreComite () // Return: Dico<std::string, std::string> //////////////////////////////////////////////////////////////////////// Dico<std::string, std::string> Conference::getInfoMembreComite (void) const { return this->infoMembreComite; } //////////////////////////////////////////////////////////////////////// // Name: Conference::getPaiement () // Purpose: Implementation of Conference::getPaiement () // Return: std::map<std::string, int> //////////////////////////////////////////////////////////////////////// std::map<std::string, int> Conference::getPaiement (void) const { return this->paiement; } //////////////////////////////////////////////////////////////////////// // Name: Conference::setBudget (int newBudget) // Purpose: Implementation of Conference::setBudget () // Parameters: // - newBudget // Return: void //////////////////////////////////////////////////////////////////////// void Conference::setBudget (int newBudget) { this->budget = newBudget; } //////////////////////////////////////////////////////////////////////// // Name: Conference::setNom (std::string newNom) // Purpose: Implementation of Conference::setNom () // Parameters: // - newNom // Return: void //////////////////////////////////////////////////////////////////////// void Conference::setNom (std::string newNom) { this->nom = newNom; } //////////////////////////////////////////////////////////////////////// // Name: Conference::setLienWeb (std::string newLienWeb) // Purpose: Implementation of Conference::setLienWeb () // Parameters: // - newLienWeb // Return: void //////////////////////////////////////////////////////////////////////// void Conference::setLienWeb (std::string newLienWeb) { this->lienWeb = newLienWeb; } //////////////////////////////////////////////////////////////////////// // Name: Conference::setListeThemes (const std::vector<std::string>& newListeThemes) // Purpose: Implementation of Conference::setListeThemes () // Parameters: // - newListeThemes // Return: void //////////////////////////////////////////////////////////////////////// void Conference::setListeThemes (const std::vector<std::string>& newListeThemes) { this->listeThemes = newListeThemes; } //////////////////////////////////////////////////////////////////////// // Name: Conference::setEtatCompte (int newEtatCompte) // Purpose: Implementation of Conference::setEtatCompte () // Parameters: // - newEtatCompte // Return: void //////////////////////////////////////////////////////////////////////// void Conference::setEtatCompte (int newEtatCompte) { this->etatCompte = newEtatCompte; } //////////////////////////////////////////////////////////////////////// // Name: Conference::setReferenceCompte (int newReferenceCompte) // Purpose: Implementation of Conference::setReferenceCompte () // Parameters: // - newReferenceCompte // Return: void //////////////////////////////////////////////////////////////////////// void Conference::setReferenceCompte (int newReferenceCompte) { this->referenceCompte = newReferenceCompte; } //////////////////////////////////////////////////////////////////////// // Name: Conference::setPapierAccepte (const Dico<Papier, std::string>& newPapierAccepte) // Purpose: Implementation of Conference::setPapierAccepte () // Parameters: // - newPapierAccepte // Return: void //////////////////////////////////////////////////////////////////////// void Conference::setPapierAccepte (const Dico<Papier, std::string>& newPapierAccepte) { this->papierAccepte = newPapierAccepte; } //////////////////////////////////////////////////////////////////////// // Name: Conference::setInfoMembreComite (const Dico<std::string, std::string>& newInfoMembreComite) // Purpose: Implementation of Conference::setInfoMembreComite () // Parameters: // - newInfoMembreComite // Return: void //////////////////////////////////////////////////////////////////////// void Conference::setInfoMembreComite (const Dico<std::string, std::string>& newInfoMembreComite) { this->infoMembreComite = newInfoMembreComite; } //////////////////////////////////////////////////////////////////////// // Name: Conference::setPaiement (std::map<std::string, int> newPaiement) // Purpose: Implementation of Conference::setPaiement () // Parameters: // - newPaiement // Return: void //////////////////////////////////////////////////////////////////////// void Conference::setPaiement (const std::map<std::string, int>& newPaiement) { this->paiement = newPaiement; } //////////////////////////////////////////////////////////////////////// // Name: Conference::saisieComite () // Purpose: Implementation of Conference::saisieComite () // Return: void //////////////////////////////////////////////////////////////////////// void Conference::saisieComite (void) { // TODO : implement } //////////////////////////////////////////////////////////////////////// // Name: Conference::affichageMontantPayer () // Purpose: Implementation of Conference::affichageMontantPayer () // Return: void //////////////////////////////////////////////////////////////////////// void Conference::affichageMontantPayer (std::ostream& os) const { for (std::map<std::string,int>::const_iterator it=this->paiement.begin ();it!=this->paiement.end ();it++) { os << it->first << "->" << it->second; } } //////////////////////////////////////////////////////////////////////// // Name: Conference::operator=(const Conference& c) // Purpose: Implementation of Conference::affichage () // Parameters: // - c // Return: Conference& //////////////////////////////////////////////////////////////////////// Conference& Conference::operator=(const Conference& c) { if (this != &c) { this->budget = c.budget; this->nom = c.nom; this->lienWeb = c.lienWeb; this->etatCompte = c.etatCompte; this->referenceCompte = c.referenceCompte; this->papierAccepte = c.papierAccepte; this->infoMembreComite = c.infoMembreComite; this->paiement = c.paiement; } return *this; }
Papier.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
50
51
52
53
54
55
56
57
58
59
60 /*********************************************************************** * Module: Papier.h * Author: scary * Modified: mardi 30 mars 2010 13:15:22 * Purpose: Declaration of the class Papier ***********************************************************************/ #ifndef PAPIER_H #define PAPIER_H #include "TypePapier.h" #include "EtatPapier.h" #include <vector> #include <string> class Papier { private: static std::vector<Papier*> Instances; Papier *papierInitial; int position; TypePapier::Type typePapier; EtatPapier::Etat etatPapier; std::string contenuPapier; std::string titrePapier; // en declarant prives le contructeur par copie et la surcharge de l'operateur affectation toute utilisation en dehors de // la classe Papier produira une erreur de compilation, et en ne les definissant pas toute utilisation produira une // erreur à l'edition de lien. Dans tout les cas le programme ne peut pas etre produit s'il y a une utilisation de l'un d'eux Papier (const Papier& papier); Papier& operator=(const Papier& p); public: Papier (TypePapier::Type newType, std::string newTitre, std::string newContenu); virtual ~Papier(); virtual TypePapier::Type getType (void) const; virtual EtatPapier::Etat getEtat (void) const; virtual Papier* getPapierInitial (void) const; virtual std::string getTitre (void) const; virtual std::string getContenu (void) const; virtual void setPapierInitial (Papier* newPapierInitial); virtual void setType (TypePapier::Type newType); virtual void setEtat (EtatPapier::Etat newEtatPapier); virtual void setTitre (std::string newTitre); virtual void setContenu (std::string newContenu); virtual void affichage (std::ostream& os) const; static void affichage (std::ostream& os, TypePapier::Type type); static void affichage (std::ostream& os, EtatPapier::Etat etat); }; inline std::ostream& operator<<(std::ostream& os, const Papier& p) { p.affichage (os); return os; } #endif
TypePapier.h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268 /*********************************************************************** * Module: Papier.cpp * Author: scary * Modified: mardi 30 mars 2010 13:15:22 * Purpose: Implementation of the class Papier ***********************************************************************/ #include "Papier.h" std::vector<Papier*> Papier::Instances; //////////////////////////////////////////////////////////////////////// // Name: Papier::Papier (TypePapier::Type type, std::string titre, std::string contenu) // Purpose: Implementation of Papier::Papier () // Parameters: // - type // - titre // - contenu //////////////////////////////////////////////////////////////////////// Papier::Papier (TypePapier::Type type, std::string titre, std::string contenu) : typePapier (type), etatPapier (EtatPapier::Soumis), papierInitial (0), titrePapier (titre), contenuPapier (contenu) { Instances.push_back (this); this->position = Instances.size () - 1; } //////////////////////////////////////////////////////////////////////// // Name: Papier::~Papier () // Purpose: Implementation of Papier::~Papier () //////////////////////////////////////////////////////////////////////// Papier::~Papier () { Instances.erase (Instances.begin () + this->position); } //////////////////////////////////////////////////////////////////////// // Name: Papier::getType () const // Purpose: Implementation of Papier::getType () // Return: TypePapier::Type //////////////////////////////////////////////////////////////////////// TypePapier::Type Papier::getType (void) const { return this->typePapier; } //////////////////////////////////////////////////////////////////////// // Name: Papier::getTitre () const // Purpose: Implementation of Papier::getTitre () // Return: std::string //////////////////////////////////////////////////////////////////////// std::string Papier::getTitre (void) const { return this->titrePapier; } //////////////////////////////////////////////////////////////////////// // Name: Papier::getContenu () const // Purpose: Implementation of Papier::getContenu () // Return: std::string //////////////////////////////////////////////////////////////////////// std::string Papier::getContenu (void) const { return this->contenuPapier; } //////////////////////////////////////////////////////////////////////// // Name: Papier::getEtat () const // Purpose: Implementation of Papier::getEtat () // Return: EtatPapier::Etat //////////////////////////////////////////////////////////////////////// EtatPapier::Etat Papier::getEtat (void) const { return this->etatPapier; } //////////////////////////////////////////////////////////////////////// // Name: Papier::getPapierInitial () const // Purpose: Implementation of Papier::getPapierInitial () // Return: Papier //////////////////////////////////////////////////////////////////////// Papier* Papier::getPapierInitial (void) const { return this->papierInitial; } //////////////////////////////////////////////////////////////////////// // Name: Papier::setPapierInitial (Papier newPapierInitial) // Purpose: Implementation of Papier::setPapierInitial () // Parameters: // - newPapierInitial // Return: void //////////////////////////////////////////////////////////////////////// void Papier::setPapierInitial (Papier* newPapierInitial) { if (papierInitial != 0) { // Un papier initial ne peut etre affecte qu'une seule fois // Associer un papier initial ne peut avoir de sens que si le papier est dans l'etat accepte delete papierInitial; } this->papierInitial = newPapierInitial; } //////////////////////////////////////////////////////////////////////// // Name: Papier::setContenu (std::string newContenu) // Purpose: Implementation of Papier::setContenu () // Parameters: // - newContenu // Return: void //////////////////////////////////////////////////////////////////////// void Papier::setContenu (std::string newContenu) { this->contenuPapier = newContenu; } //////////////////////////////////////////////////////////////////////// // Name: Papier::setTitre (std::string newTitre) // Purpose: Implementation of Papier::setTitre () // Parameters: // - newTitre // Return: void //////////////////////////////////////////////////////////////////////// void Papier::setTitre (std::string newTitre) { this->titrePapier = newTitre; } //////////////////////////////////////////////////////////////////////// // Name: Papier::setType (TypePapier::Type newType) // Purpose: Implementation of Papier::setType () // Parameters: // - newType // Return: void //////////////////////////////////////////////////////////////////////// void Papier::setType (TypePapier::Type newType) { this->typePapier = newType; } //////////////////////////////////////////////////////////////////////// // Name: Papier::setEtat (EtatPapier::Etat newEtat) // Purpose: Implementation of Papier::setEtat () // Parameters: // - newEtat // Return: void //////////////////////////////////////////////////////////////////////// void Papier::setEtat (EtatPapier::Etat newEtat) { this->etatPapier = newEtat; } //////////////////////////////////////////////////////////////////////// // Name: Papier::affichage (std::ostream& os, EtatPapier::Etat etat) // Purpose: Implementation of Papier::affichage () // Parameters: // - etat // - os // Return: void //////////////////////////////////////////////////////////////////////// void Papier::affichage (std::ostream& os, EtatPapier::Etat etat) { for (std::vector<Papier*>::iterator it = Instances.begin ();it!=Instances.end ();it++) { if ((*it)->etatPapier == etat) { (*it)->affichage (os); os << std::endl; } } } //////////////////////////////////////////////////////////////////////// // Name: Papier::affichage (std::ostream& os, TypePapier::Type type) // Purpose: Implementation of Papier::affichage () // Parameters: // - type // - os // Return: void //////////////////////////////////////////////////////////////////////// void Papier::affichage (std::ostream& os, TypePapier::Type type) { for (std::vector<Papier*>::iterator it = Instances.begin ();it!=Instances.end ();it++) { if ((*it)->typePapier == type) { (*it)->affichage (os); os << std::endl; } } } //////////////////////////////////////////////////////////////////////// // Name: Papier::affichage (std::ostream& os) const // Purpose: Implementation of Papier::affichage () // Parameters: // - os // Return: void //////////////////////////////////////////////////////////////////////// void Papier::affichage (std::ostream& os) const { switch (etatPapier) { case (0): { os << "Soumis "; break; } case (1): { os << "Accepte "; break; } default: { os << "Refuse "; break; } } switch (typePapier) { case (0): { os << "Court "; break; } case (1): { os << "Grand "; break; } case (2): { os << "Recherche "; break; } case (3): { os << "Industriel "; break; } case (4): { os << "Tutoriel "; break; } default: { os << "Poster "; break; } } os << titrePapier; }
EtatPapier.h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 /*********************************************************************** * Module: TypePapier.h * Author: scary * Modified: mardi 30 mars 2010 13:15:22 * Purpose: Declaration of the class TypePapier ***********************************************************************/ #ifndef TYPEPAPIER_H #define TYPEPAPIER_H class TypePapier { public: enum Type { Court, Grand, Recherche, Industriel, Tutoriel, Poster }; }; #endif
main.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 /*********************************************************************** * Module: EtatPapier.h * Author: scary * Modified: mardi 30 mars 2010 13:15:22 * Purpose: Declaration of the class EtatPapier ***********************************************************************/ #ifndef ETATPAPIER_H #define ETATPAPIER_H class EtatPapier { public: enum Etat { Soumis, Accepte, Refuse }; }; #endif
Voila, alors tout ceci compile si je commente les deux constructeurs, le destructeur et l'opérateur d'affectation de "Dico". Alors que si je les laisse j'ai les erreurs suivantes:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 #include "Conference.h" int main () { return 0; }
Voila j'espère avoir été assez clair, parce que j'avoue être complétement perdu pour ce soucis Merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 1>------ Build started: Project: Test, Configuration: Debug Win32 ------ 1> Skipping... (no relevant changes detected) 1> main.cpp 1> Conference.cpp 1>Conference.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::~Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(void)" (??1?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@@UAE@XZ) referenced in function __unwindfunclet$??0Conference@@QAE@XZ$0 1>Conference.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall Dico<class Papier,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::~Dico<class Papier,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(void)" (??1?$Dico@VPapier@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@UAE@XZ) referenced in function __unwindfunclet$??0Conference@@QAE@XZ$0 1>Conference.obj : error LNK2019: unresolved external symbol "public: __thiscall Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(void)" (??0?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@@QAE@XZ) referenced in function "public: __thiscall Conference::Conference(void)" (??0Conference@@QAE@XZ) 1>Conference.obj : error LNK2019: unresolved external symbol "public: __thiscall Dico<class Papier,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::Dico<class Papier,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(void)" (??0?$Dico@VPapier@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAE@XZ) referenced in function "public: __thiscall Conference::Conference(void)" (??0Conference@@QAE@XZ) 1>Conference.obj : error LNK2019: unresolved external symbol "public: __thiscall Dico<class Papier,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::Dico<class Papier,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class Dico<class Papier,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > const &)" (??0?$Dico@VPapier@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAE@ABV0@@Z) referenced in function "public: virtual class Dico<class Papier,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > __thiscall Conference::getPapierAccepte(void)const " (?getPapierAccepte@Conference@@UBE?AV?$Dico@VPapier@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@XZ) 1>Conference.obj : error LNK2019: unresolved external symbol "public: __thiscall Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > const &)" (??0?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@@QAE@ABV0@@Z) referenced in function "public: virtual class Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > __thiscall Conference::getInfoMembreComite(void)const " (?getInfoMembreComite@Conference@@UBE?AV?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@@XZ) 1>C:\Users\Scary\Documents\Visual Studio 2010\Projects\Test\Debug\Test.exe : fatal error LNK1120: 6 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Partager