Template avec des pointeurs
Bonjour,
J'ai créé une classe Liste et maillon en template pour créé une liste chaine.
Quand je fais :
Liste l1<float> ou
Liste l2<int>
sa marche aussi.
Par contre si je fait :
Liste l3<Personne*>
J'obtient comme erreur :
Citation:
Liste.cc: In member function ‘Liste<T>& Liste<T>::operator+(T) [with T = Personne*]’:
Client.cc:45: instantiated from here
Liste.cc:32: erreur: no matching function for call to ‘Maillon<Personne*>::Maillon(Personne*&)’
Maillon.cc:22: note: candidats sont: Maillon<T>::Maillon(double) [with T = Personne*]
Maillon.cc:15: note: Maillon<T>::Maillon(const Maillon<T>&) [with T = Personne*]
Maillon.cc:14: note: Maillon<T>::Maillon() [with T = Personne*]
Voici une partie de ma classe Liste :
Code:
1 2 3 4 5 6
|
// Ajout de maillons
Liste<T>& operator+(T data) {
Maillon<T> *maillon = new Maillon<T>(data);
return *this + (*maillon);
} |
et ma classe Maillon :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
template<class T>
class Maillon
{
private:
T data;
Maillon<T> *suiv;
public:
Maillon() : data(0), suiv(NULL){};
Maillon(const Maillon<T>& e) : data(e.data), suiv(e.suiv){};
~Maillon(){};
Maillon<T>& operator=(const Maillon<T>& e) {
data = e.data;
suiv = e.suiv;
return *this;
}
Maillon(double d) : data(d), suiv(NULL){};
template<class D> friend class Liste;
}; |
Si vous pouviez m'aider ?
Merci d'avance