problème constructeur copie noeud (arbre)
bonjour tout le monde.
je code un arbre binaire et j'ai un problème dans mon constructeur de copie de noeud. (il faut dire que je suis plutot habituer au java et avec le C++ j'ai plutôt du mal)
je vous met le code source :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| class noeud {
private:
char val[10];
noeud *inf();
noeud *sup();
public:
noeud(const noeud &n);
noeud(noeud &n,std::string a, std::string b);
noeud(std::string a, std::string b, std::string c);
noeud(std::string a);
virtual ~noeud();
int calcul(void);
}; |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| #include "noeud.h"
noeud::noeud(const noeud & n){
inf = new noeud(n.inf);
sup = new noeud(n.sup);
val = n.val;
}
noeud::noeud(noeud &n,std::string a, std::string b){
inf = new noeud(n);
val = a;
sup->b;
}
etc... |
le problème se trouve au niveaux de inf = new noeud(n.inf);
le constructeur de copie se rappel lui même dans le nœud qui suit ect.
voila le msg du compilateur
Code:
1 2 3 4 5
| |12|error: no matching function for call to `noeud::noeud(<unknown type>)'|
|25|note: candidates are: noeud::noeud(std::string)|
|24|note: noeud::noeud(std::string, std::string, std::string)|
|22|note: noeud::noeud(noeud&, std::string, std::string)|
|21|note: noeud::noeud(const noeud&)| |
il ne reconnait apparemment pas n.inf mais je ne vois pas coi faire pour résoudre le problème.
Merci de votre aide!