IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++ Discussion :

Problème lors d'édition de lien


Sujet :

C++

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    327
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 327
    Points : 114
    Points
    114
    Par défaut Problème lors d'édition de lien
    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

    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
    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
    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.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
    /***********************************************************************
     * 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
    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
    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.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
    /***********************************************************************
     * 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
    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
    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.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
    /***********************************************************************
     * 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
    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
    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;
    }
    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
    /***********************************************************************
     * 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
    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
    /***********************************************************************
     * 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
    main.cpp

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    #include "Conference.h"
     
    int main ()
    {
    	return 0;
    }
    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
    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 ==========
    Voila j'espère avoir été assez clair, parce que j'avoue être complétement perdu pour ce soucis Merci d'avance

  2. #2
    Modérateur
    Avatar de bruno_pages
    Homme Profil pro
    ingénieur informaticien à la retraite
    Inscrit en
    Juin 2005
    Messages
    3 533
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : ingénieur informaticien à la retraite
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juin 2005
    Messages : 3 533
    Points : 6 709
    Points
    6 709
    Par défaut
    Bonjour,

    les opérations des classes template qui sont liées au paramètre formels doivent être définie dans les .h, pas dans les .cpp

    vous devez considérer que les classes template définissent en quelque sorte des macros que le compilateur expanse
    Bruno Pagès, auteur de Bouml (freeware), mes tutoriels sur DVP (vieux, non à jour )

    N'oubliez pas de consulter les FAQ UML et les cours et tutoriels UML

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    327
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 327
    Points : 114
    Points
    114
    Par défaut
    En effet c'était bien cela, j'ai donc remplacer les inclusion du .h par le.cpp mais maintenant un problème que je n'avais pas du tout prévu (pour en revenir à notre problème de constructeur par copie et de redéfinition d'affectation dans ma classe Papier si vous vous souvenez)

    Puisque maintenant lors de la compilation j'ai l'erreur suivante:

    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
    1>------ Build started: Project: Test, Configuration: Debug Win32 ------
    1>  Conference.cpp
    1>c:\users\scary\documents\visual studio 2010\projects\test\test\dico.cpp(44): error C2248: 'Papier::Papier' : cannot access private member declared in class 'Papier'
    1>          c:\users\scary\documents\visual studio 2010\projects\test\test\papier.h(31) : see declaration of 'Papier::Papier'
    1>          c:\users\scary\documents\visual studio 2010\projects\test\test\papier.h(18) : see declaration of 'Papier'
    1>          c:\users\scary\documents\visual studio 2010\projects\test\test\dico.cpp(39) : while compiling class template member function 'Dico<TypeCle,TypeValeur>::Dico(void)'
    1>          with
    1>          [
    1>              TypeCle=Papier,
    1>              TypeValeur=std::string
    1>          ]
    1>          c:\users\scary\documents\visual studio 2010\projects\test\test\conference.h(26) : see reference to class template instantiation 'Dico<TypeCle,TypeValeur>' being compiled
    1>          with
    1>          [
    1>              TypeCle=Papier,
    1>              TypeValeur=std::string
    1>          ]
    1>  Generating Code...
    1>  Compiling...
    1>  Papier.cpp
    1>  Generating Code...
    1>  Compiling...
    1>  main.cpp
    1>c:\users\scary\documents\visual studio 2010\projects\test\test\assoc.h(29): error C2248: 'Papier::operator =' : cannot access private member declared in class 'Papier'
    1>          c:\users\scary\documents\visual studio 2010\projects\test\test\papier.h(32) : see declaration of 'Papier::operator ='
    1>          c:\users\scary\documents\visual studio 2010\projects\test\test\papier.h(18) : see declaration of 'Papier'
    1>          This diagnostic occurred in the compiler generated function 'Assoc<TypeCle,TypeValeur> &Assoc<TypeCle,TypeValeur>::operator =(const Assoc<TypeCle,TypeValeur> &)'
    1>          with
    1>          [
    1>              TypeCle=Papier,
    1>              TypeValeur=std::string
    1>          ]
    1>  Generating Code...
    1>  Skipping... (no relevant changes detected)
    1>  Dico.cpp
    1>  Assoc.cpp
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    J'ai donc bien l'impression qu'il va falloir définir le constructeur par copie et l'opérateur d'affectation au lieu de les mettres en privées seulement je ne vois toujours pas comment

  4. #4
    Modérateur
    Avatar de bruno_pages
    Homme Profil pro
    ingénieur informaticien à la retraite
    Inscrit en
    Juin 2005
    Messages
    3 533
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : ingénieur informaticien à la retraite
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juin 2005
    Messages : 3 533
    Points : 6 709
    Points
    6 709
    Par défaut
    il avait été décidé qu'il ne devait pas y avoir de recopie/affectation de Papier, c'est à dire qu'ils étaient manipulés via des pointeurs.

    cela veut dire qu'il ne faut pas utiliser de Dico<Papier, string> mais Dico<Papier*, string>

    ceci dit je suis étonné que la clef soit un Papier et la valeur une string, et pas seulement parce que == n'est pas défini sur Papier, cela ne devrait pas être l'inverse c.a.d. la recherche d'un Papier à partir d'une string (exemple son titre) ? que représente la string ?

    sinon, pourquoi avoir défini Dico et ne pas avoir utilisé std::map ?
    Bruno Pagès, auteur de Bouml (freeware), mes tutoriels sur DVP (vieux, non à jour )

    N'oubliez pas de consulter les FAQ UML et les cours et tutoriels UML

  5. #5
    Membre régulier
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    327
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 327
    Points : 114
    Points
    114
    Par défaut
    La string corresponds au nom de l'auteur du papier. Et je dois utiliser une structure de données de type Map qu'on devait faire nous même pour cet attribut sinon c'est sur que j'aurais utilisé un map

  6. #6
    Membre régulier
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    327
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 327
    Points : 114
    Points
    114
    Par défaut
    Toujours un problème d'édition de lien

    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>  Conference.cpp
    1>  Generating Code...
    1>  Compiling...
    1>  main.cpp
    1>  Generating Code...
    1>Conference.obj : error LNK2001: unresolved external symbol "private: static 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> > >::valeurDefaut" (?valeurDefaut@?$Dico@PAVPapier@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)
    1>Conference.obj : error LNK2001: unresolved external symbol "private: static class Papier * Dico<class Papier *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::cleDefaut" (?cleDefaut@?$Dico@PAVPapier@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@0PAVPapier@@A)
    1>Conference.obj : error LNK2001: unresolved external symbol "private: static 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> > >::valeurDefaut" (?valeurDefaut@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)
    1>Conference.obj : error LNK2001: unresolved external symbol "private: static 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> > >::cleDefaut" (?cleDefaut@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)
    1>C:\Users\Scary\Documents\Visual Studio 2010\Projects\Test\Debug\Test.exe : fatal error LNK1120: 4 unresolved externals
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

  7. #7
    Modérateur
    Avatar de bruno_pages
    Homme Profil pro
    ingénieur informaticien à la retraite
    Inscrit en
    Juin 2005
    Messages
    3 533
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : ingénieur informaticien à la retraite
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juin 2005
    Messages : 3 533
    Points : 6 709
    Points
    6 709
    Par défaut
    Citation Envoyé par scary Voir le message
    La string corresponds au nom de l'auteur du papier. Et je dois utiliser une structure de données de type Map qu'on devait faire nous même pour cet attribut sinon c'est sur que j'aurais utilisé un map
    le but est vraiment de retrouver l'auteur à partir du papier en passant via cette map ?
    il aurait suffit de mettre le nom de l'auteur en attribut dans Papier et pas besoin de map

    par contre retrouver un papier à partir du nom d'un auteur parait nettement plus utile (on suppose qu'un auteur ne soumet qu'un papier, pas plusieurs)

    encore une fois, vous êtes vraiment absolument certain d'être sure de ne pas faire les choses à l'envers ?
    Bruno Pagès, auteur de Bouml (freeware), mes tutoriels sur DVP (vieux, non à jour )

    N'oubliez pas de consulter les FAQ UML et les cours et tutoriels UML

  8. #8
    Membre régulier
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    327
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 327
    Points : 114
    Points
    114
    Par défaut
    Tiré de l'énoncé:

    Vous définirez un type dictionnaire agissant de la même manière qu'un conteneur de type Map qui servira pour les attribut suivant de la classe Conference:

    - Pour les papier acceptés: papier accepté, nom de l'auteur correspondant
    - Pour associer des noms d'auteurs de papiers avec leur adresses mail

  9. #9
    Modérateur
    Avatar de bruno_pages
    Homme Profil pro
    ingénieur informaticien à la retraite
    Inscrit en
    Juin 2005
    Messages
    3 533
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : ingénieur informaticien à la retraite
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juin 2005
    Messages : 3 533
    Points : 6 709
    Points
    6 709
    Par défaut
    ok

    on va supposer qu'il n'est pas nécessaire de définir l'opérateur == sur Papier, c'est à dire qu'on manipule toujours un Papier via un pointeur, qu'il n'y a pas de clone, et donc que l'égalité de Papier* correspond en fait à l'égalité de Papier. Il faut dire cela en commentaire pour expliquer que la recherche avec == dans la map fait bien ce que l'on attend dans le cas des Papier.

    ce que le linker ne trouve pas ce sont les clef et valeur par défaut

    pourquoi la chaine par défaut n'est pas simplement une chaine vide ? cela va mal se passer si un auteur s'appelle rien

    je regarderai plus tard plus en détail votre implémentation de Dico qui me semble 'bizarre'
    Bruno Pagès, auteur de Bouml (freeware), mes tutoriels sur DVP (vieux, non à jour )

    N'oubliez pas de consulter les FAQ UML et les cours et tutoriels UML

  10. #10
    Membre régulier
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    327
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 327
    Points : 114
    Points
    114
    Par défaut
    Je peux pas initialiser une chose dont je ne connais pas le type à l'avance non ?

    Enfin dans mon Dico, sinon autant marquer explicitement les types et ne pas faire de template ?

    Oui je pense que j'ai fais pas mal de bourde dans ma classe Dico puisque la preuve ça compile même pas

    Je vais aussi de mon côté la revoir. Je pense que le problème doit venir de la méthode "hash".

  11. #11
    Modérateur
    Avatar de bruno_pages
    Homme Profil pro
    ingénieur informaticien à la retraite
    Inscrit en
    Juin 2005
    Messages
    3 533
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : ingénieur informaticien à la retraite
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juin 2005
    Messages : 3 533
    Points : 6 709
    Points
    6 709
    Par défaut
    juste en passant (je ne peux faire plus en ce moment) :

    une table de hachage est comme vous le savez un vecteur de taille dynamique (pour grossir au fur et à mesure) dont chaque entrée est une séquence peut être vide de couples clef-valeur. Les séquences peut éventuellement est triée pour accélérer encore les choses

    l'index dans le vecteur est donné par la fonction de hachage modulo la taille du vecteur (lorsque la taille est un nombre premier le résultât est généralement meilleur), la séquence de couple permettant de gérer les synonymies (même valeur de hachage % taille). Le vecteur interne grossi au fur et à mesure qu'on ajoute des éléments pour minimiser le nombre de synonymes.

    le vecteur interne est donc soit de type Assoc<TypeCle, TypeValeur> ** si Assoc gère le chainage des associations synonymes, soit de type list<Assoc<TypeCle, TypeValeur> >* , par contre je ne comprends pas qu'il puisse être de type Assoc<TypeCle, TypeValeur> *
    Bruno Pagès, auteur de Bouml (freeware), mes tutoriels sur DVP (vieux, non à jour )

    N'oubliez pas de consulter les FAQ UML et les cours et tutoriels UML

  12. #12
    Membre régulier
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    327
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 327
    Points : 114
    Points
    114
    Par défaut
    Voici les nouvelles version de Dico.h et Dico.cpp:

    .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
    /***********************************************************************
     * 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.cpp"
    #include "Papier.h"
     
    #include <ctime>
     
    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
    le .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
    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
    /***********************************************************************
     * 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 () != 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 (cleDefaut);
    					this->tabAssoc[j]->setValeur (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 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 () != 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<>
    int Dico<Papier*, int>::hash (Papier* s, int tailleTab)
    {
    	srand ((unsigned int)time (0));
    	int i = rand () % 100 + 1;
     
    	return i % tailleTab;
    }
     
    template<> 
    std::string Dico<std::string, std::string>::cleDefaut = "";
     
    template<> 
    std::string Dico<std::string, std::string>::valeurDefaut = "";
     
    template 
    class Dico<std::string, std::string>;
     
    template 
    	std::ostream& operator<<(std::ostream& os, const Dico<std::string, std::string>& dico);
     
    template<> 
    Papier* Dico<Papier*, std::string>::cleDefaut = 0;
     
    template 
    class Dico<Papier*, std::string>;
     
    template 
    	std::ostream& operator<<(std::ostream& os, const Dico<Papier*, std::string>& dico);
    Mais j'ai de nouveaux warning

    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
    1>------ Build started: Project: TP_NOTE, Configuration: Release Win32 ------
    1>  Dico.cpp
    1>c:\users\scary\documents\visual studio 2010\projects\tp_note\tp_note\Dico.h(41): warning C4661: 'int Dico<TypeCle,TypeValeur>::hash(TypeCle,int)' : no suitable definition provided for explicit template instantiation request
    1>          with
    1>          [
    1>              TypeCle=std::string,
    1>              TypeValeur=std::string
    1>          ]
    1>          c:\users\scary\documents\visual studio 2010\projects\tp_note\tp_note\Dico.h(39) : see declaration of 'Dico<TypeCle,TypeValeur>::hash'
    1>          with
    1>          [
    1>              TypeCle=std::string,
    1>              TypeValeur=std::string
    1>          ]
    1>c:\users\scary\documents\visual studio 2010\projects\tp_note\tp_note\Dico.h(41): warning C4661: 'int Dico<TypeCle,TypeValeur>::hash(TypeCle,int)' : no suitable definition provided for explicit template instantiation request
    1>          with
    1>          [
    1>              TypeCle=Papier *,
    1>              TypeValeur=std::string
    1>          ]
    1>          c:\users\scary\documents\visual studio 2010\projects\tp_note\tp_note\Dico.h(39) : see declaration of 'Dico<TypeCle,TypeValeur>::hash'
    1>          with
    1>          [
    1>              TypeCle=Papier *,
    1>              TypeValeur=std::string
    1>          ]
    1>c:\users\scary\documents\visual studio 2010\projects\tp_note\tp_note\Dico.h(41): warning C4661: 'std::string Dico<TypeCle,TypeValeur>::valeurDefaut' : no suitable definition provided for explicit template instantiation request
    1>          with
    1>          [
    1>              TypeCle=Papier *,
    1>              TypeValeur=std::string
    1>          ]
    1>          c:\users\scary\documents\visual studio 2010\projects\tp_note\tp_note\Dico.h(24) : see declaration of 'Dico<TypeCle,TypeValeur>::valeurDefaut'
    1>          with
    1>          [
    1>              TypeCle=Papier *,
    1>              TypeValeur=std::string
    1>          ]
    1>Dico.cpp(12): warning C4661: 'int Dico<TypeCle,TypeValeur>::hash(TypeCle,int)' : no suitable definition provided for explicit template instantiation request
    1>          with
    1>          [
    1>              TypeCle=std::string,
    1>              TypeValeur=std::string
    1>          ]
    1>          c:\users\scary\documents\visual studio 2010\projects\tp_note\tp_note\Dico.h(39) : see declaration of 'Dico<TypeCle,TypeValeur>::hash'
    1>          with
    1>          [
    1>              TypeCle=std::string,
    1>              TypeValeur=std::string
    1>          ]
    1>Dico.cpp(12): warning C4661: 'int Dico<TypeCle,TypeValeur>::hash(TypeCle,int)' : no suitable definition provided for explicit template instantiation request
    1>          with
    1>          [
    1>              TypeCle=Papier *,
    1>              TypeValeur=std::string
    1>          ]
    1>          c:\users\scary\documents\visual studio 2010\projects\tp_note\tp_note\Dico.h(39) : see declaration of 'Dico<TypeCle,TypeValeur>::hash'
    1>          with
    1>          [
    1>              TypeCle=Papier *,
    1>              TypeValeur=std::string
    1>          ]
    1>Dico.cpp(12): warning C4661: 'std::string Dico<TypeCle,TypeValeur>::valeurDefaut' : no suitable definition provided for explicit template instantiation request
    1>          with
    1>          [
    1>              TypeCle=Papier *,
    1>              TypeValeur=std::string
    1>          ]
    1>          c:\users\scary\documents\visual studio 2010\projects\tp_note\tp_note\Dico.h(24) : see declaration of 'Dico<TypeCle,TypeValeur>::valeurDefaut'
    1>          with
    1>          [
    1>              TypeCle=Papier *,
    1>              TypeValeur=std::string
    1>          ]

  13. #13
    Modérateur
    Avatar de bruno_pages
    Homme Profil pro
    ingénieur informaticien à la retraite
    Inscrit en
    Juin 2005
    Messages
    3 533
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : ingénieur informaticien à la retraite
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juin 2005
    Messages : 3 533
    Points : 6 709
    Points
    6 709
    Par défaut
    ces message apparaissent lorsque vous compilez Dico.cpp ?

    je n'ai pas de warning ni erreur lorsque je compile Dico.cpp sous Linux

    par contre le fait que des définitions d'opération de Dico soient encore dans le source et non le .h vous posera des problèmes d'édition des lien

    votre #include "Assoc.cpp" n'est pas bien beau

    encore une fois vous devez mettre les définitions dés opération utilisant les types formels dans le .h, pas dans un .cpp inclue dans un .h, et cela pas seulement pour Assoc mais dans tout les cas
    Bruno Pagès, auteur de Bouml (freeware), mes tutoriels sur DVP (vieux, non à jour )

    N'oubliez pas de consulter les FAQ UML et les cours et tutoriels UML

  14. #14
    Membre régulier
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    327
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 327
    Points : 114
    Points
    114
    Par défaut
    Oui et ce ne sont pas les seuls, voila la sortie du compilateur en entier:

    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
    1>------ Build started: Project: TP_NOTE, Configuration: Release Win32 ------
    1>  Dico.cpp
    1>c:\users\scary\documents\visual studio 2010\projects\tp_note\tp_note\Dico.h(41): warning C4661: 'int Dico<TypeCle,TypeValeur>::hash(TypeCle,int)' : no suitable definition provided for explicit template instantiation request
    1>          with
    1>          [
    1>              TypeCle=std::string,
    1>              TypeValeur=std::string
    1>          ]
    1>          c:\users\scary\documents\visual studio 2010\projects\tp_note\tp_note\Dico.h(39) : see declaration of 'Dico<TypeCle,TypeValeur>::hash'
    1>          with
    1>          [
    1>              TypeCle=std::string,
    1>              TypeValeur=std::string
    1>          ]
    1>c:\users\scary\documents\visual studio 2010\projects\tp_note\tp_note\Dico.h(41): warning C4661: 'int Dico<TypeCle,TypeValeur>::hash(TypeCle,int)' : no suitable definition provided for explicit template instantiation request
    1>          with
    1>          [
    1>              TypeCle=Papier *,
    1>              TypeValeur=std::string
    1>          ]
    1>          c:\users\scary\documents\visual studio 2010\projects\tp_note\tp_note\Dico.h(39) : see declaration of 'Dico<TypeCle,TypeValeur>::hash'
    1>          with
    1>          [
    1>              TypeCle=Papier *,
    1>              TypeValeur=std::string
    1>          ]
    1>Dico.cpp(12): warning C4661: 'int Dico<TypeCle,TypeValeur>::hash(TypeCle,int)' : no suitable definition provided for explicit template instantiation request
    1>          with
    1>          [
    1>              TypeCle=std::string,
    1>              TypeValeur=std::string
    1>          ]
    1>          c:\users\scary\documents\visual studio 2010\projects\tp_note\tp_note\Dico.h(39) : see declaration of 'Dico<TypeCle,TypeValeur>::hash'
    1>          with
    1>          [
    1>              TypeCle=std::string,
    1>              TypeValeur=std::string
    1>          ]
    1>Dico.cpp(12): warning C4661: 'int Dico<TypeCle,TypeValeur>::hash(TypeCle,int)' : no suitable definition provided for explicit template instantiation request
    1>          with
    1>          [
    1>              TypeCle=Papier *,
    1>              TypeValeur=std::string
    1>          ]
    1>          c:\users\scary\documents\visual studio 2010\projects\tp_note\tp_note\Dico.h(39) : see declaration of 'Dico<TypeCle,TypeValeur>::hash'
    1>          with
    1>          [
    1>              TypeCle=Papier *,
    1>              TypeValeur=std::string
    1>          ]
    1>Dico.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>DocteurIngenieur.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>Entreprise.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>Etudiant.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>EtudiantCifre.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>EtudiantCifreEnseignant.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>Industriel.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>Ingenieur.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>PersonneIndustrielle.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>PersonnelTechnique.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>Secretaire.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>Technicien.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>Conference.obj : error LNK2001: unresolved external symbol "public: static int __cdecl Dico<class Papier *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::hash(class Papier *,int)" (?hash@?$Dico@PAVPapier@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@SAHPAVPapier@@H@Z)
    1>C:\Users\scary\Documents\Visual Studio 2010\Projects\TP_NOTE\Release\TP_NOTE.exe : fatal error LNK1120: 1 unresolved externals
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    Sinon qu'elle est la différence entre faire toutes les définitions des méthodes de la classe dans un .h et inclure ce .h et faire de même avec un .cpp ?

  15. #15
    Modérateur
    Avatar de bruno_pages
    Homme Profil pro
    ingénieur informaticien à la retraite
    Inscrit en
    Juin 2005
    Messages
    3 533
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : ingénieur informaticien à la retraite
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juin 2005
    Messages : 3 533
    Points : 6 709
    Points
    6 709
    Par défaut
    bon, commencez par mettre les définitions des opérations utilisant les paramètre formels dans les .h et non les .cpp, retirer les #include "xx.cpp" des .h et puis on verra ce que cela donne

    pour être plus clair, si on a
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    template <typename X>
    class C {
    ...
      X f1();
      void f2(X x);
      void f3();
    };
    la signature de f1 et f2 utilise le paramètre formel X, ces deux opérations doivent donc être impérativement définis dans le .h

    si le corps de f3 n'utilise pas X alors il est préférable que sa définition soit placée dans le .cpp

    par contre si le corps de f3 utilise X, quel qu'en soit la raison, alors il faut que la définition de f3 soit placée dans le .h
    Bruno Pagès, auteur de Bouml (freeware), mes tutoriels sur DVP (vieux, non à jour )

    N'oubliez pas de consulter les FAQ UML et les cours et tutoriels UML

  16. #16
    Membre régulier
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    327
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 327
    Points : 114
    Points
    114
    Par défaut
    Très bien j'ai donc mis toutes les définitions dans le .h, cela à eu comme avantage d'enlever les warning. Voici donc le nouveau .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
    /***********************************************************************
     * 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.cpp"
    #include "Papier.h"
     
    #include <ctime>
     
    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
    		{
    			int j = 4hash (cl, this->tailleT);
     
    			i = j;
    			res = 0;
     
    			while (this->tabAssoc[i]->getCle () != cleDefaut && this->tabAssoc[i]->getCle () != cl && res != 2)
    			{
    				i++;
     
    				if (i == this->tailleT)
    				{
    					i = 0;
    				}
    				if (i == j)
    				{
    					res = 2;
    				}
    			}
    			if (this->tabAssoc[i]->getCle () == cl)
    			{
    				res = 1;
    			}
    		}
     
    	public :
    		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;
    		}
    		Dico (const Dico& 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];
    			}
    		}
    		virtual ~Dico ()
    		{
    			delete[] this->tabAssoc;
    		}
    		void 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 (cleDefaut);
    							this->tabAssoc[j]->setValeur (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;
    			}
    		}
    		TypeValeur get (const TypeCle& c) const
    		{
    			int i;
    			int res;
     
    			CherchCl (c, i, res);
     
    			if (res == 1)
    			{
    				return this->tabAssoc[i]->getValeur ();
    			}
    			else
    			{
    				return valeurDefaut;
    			}
    		}
    		bool estVide () const
    		{
    			return this->nbAssoc == 0;
    		}
    		int taille () const
    		{
    			return this->nbAssoc;
    		}
    		bool contient (const TypeCle& cle) const
    		{
    			int i;
    			int res;
     
    			CherchCl (cle, i, res);
     
    			return res == 1;
    		}
    		void 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 () != cleDefaut)
    					{
    						os << this->tabAssoc[i]->getCle () << "->" << this->tabAssoc[i]->getValeur () << std::endl;
    					}
    				}
    			}
    		}
    		void supprime (const TypeCle& cle)
    		{
    			if (this->contient (cle))
    			{
    				for (int i=0;i<this->tailleT;i++)
    				{
    					if (this->tabAssoc[i]->getCle () == cle)
    					{
     
    					}
    				}
    			}
    			else
    			{
    				std::cout << "La valeur n'existe pas" << std::endl;
    			}
    		}
    		static int hash (TypeCle s, int tailleTab)
    		{
    			srand ((unsigned int)time (0));
    			int i = rand () % 100 + 1;
     
    			return i % tailleTab;
    		}
    		virtual Dico& operator=(const Dico& 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;
    		}
    		std::string Dico<std::string, std::string>::cleDefaut = "";
    		std::string Dico<std::string, std::string>::valeurDefaut = "";
    		class Dico<std::string, std::string>;
    		Papier* Dico<Papier*, std::string>::cleDefaut = 0;
    		std::string Dico<Papier*, std::string>::valeurDefaut = "";
    		class Dico<Papier*, std::string>;
    };
     
    template <typename TypeCle, typename TypeValeur>
    std::ostream& operator<<(std::ostream& os, const Dico<TypeCle, TypeValeur>& dico)
    {
    	dico.affiche (os);
     
    	return os;
    }
     
    #endif
    et les messages du compilateur:

    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
    1>------ Build started: Project: TP_NOTE, Configuration: Release Win32 ------
    1>DocteurIngenieur.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>Entreprise.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>Etudiant.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>EtudiantCifre.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>EtudiantCifreEnseignant.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>Industriel.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>Ingenieur.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>PersonneIndustrielle.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>PersonnelTechnique.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>Secretaire.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>Technicien.obj : error LNK2005: "public: static int __cdecl Dico<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int>::hash(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (?hash@?$Dico@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@@SAHV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) already defined in Conference.obj
    1>Conference.obj : error LNK2001: unresolved external symbol "public: static int __cdecl Dico<class Papier *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::hash(class Papier *,int)" (?hash@?$Dico@PAVPapier@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@SAHPAVPapier@@H@Z)
    1>Conference.obj : error LNK2001: unresolved external symbol "private: static 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> > >::valeurDefaut" (?valeurDefaut@?$Dico@PAVPapier@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)
    1>Conference.obj : error LNK2001: unresolved external symbol "private: static class Papier * Dico<class Papier *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::cleDefaut" (?cleDefaut@?$Dico@PAVPapier@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@0PAVPapier@@A)
    1>C:\Users\scary\Documents\Visual Studio 2010\Projects\TP_NOTE\Release\TP_NOTE.exe : fatal error LNK1120: 3 unresolved externals
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

  17. #17
    Modérateur
    Avatar de bruno_pages
    Homme Profil pro
    ingénieur informaticien à la retraite
    Inscrit en
    Juin 2005
    Messages
    3 533
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 64
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : ingénieur informaticien à la retraite
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juin 2005
    Messages : 3 533
    Points : 6 709
    Points
    6 709
    Par défaut
    relisez ma précédente réponse, faites tout ce que j'ai dit de faire, pas seulement le tiers ... et cela résoudra votre problème
    Bruno Pagès, auteur de Bouml (freeware), mes tutoriels sur DVP (vieux, non à jour )

    N'oubliez pas de consulter les FAQ UML et les cours et tutoriels UML

  18. #18
    Membre régulier
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    327
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 327
    Points : 114
    Points
    114
    Par défaut
    Autant pour moi

    En effet je n'avais pas fait attention à l'inclusion des .cpp

    Problème donc résolu.

    En tout cas j'ai appris une chose fort interessante aujourd'hui Merci beaucoup

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème GDI+ et édition de liens
    Par jomeo dans le forum C++
    Réponses: 7
    Dernier message: 13/02/2007, 16h52
  2. [g++] Problème d'édition de liens
    Par glKabuto dans le forum Autres éditeurs
    Réponses: 3
    Dernier message: 31/05/2006, 19h10
  3. JTable et JComboBox : problème lors de l'édition
    Par Claythest dans le forum Composants
    Réponses: 13
    Dernier message: 25/04/2006, 18h18
  4. [Dev-C++] Problème d'édition des liens
    Par shura dans le forum EDI
    Réponses: 5
    Dernier message: 30/08/2005, 09h35
  5. Problème à l'édition des liens avec BCC55 et Xerces
    Par ShootDX dans le forum Autres éditeurs
    Réponses: 4
    Dernier message: 30/11/2003, 14h50

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo