Salut à tous,
je ne vois vraiment pas pourquoi le compilo prends ça pour une variable ou champ, au lieu d'une fonction. Je précise: c'est la fonction "void afficheArbre(etat *n)"
quelqu'un a une idée?
arbre.cpp
objets.cppCode:
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 #include <iostream> #include <string> using namespace std; int recurs(0); int main(int argc,char *argv[]){ return 0; } void afficheArbre(etat *n){ int i,j; for(i=0;i<recurs;i++) cout<<"|"; i=n->getNbFils(); cout<<'-'<<endl; for(j=0;j<i;j++){ recurs++; cout<<"-"<<endl; branche(n->getFils(j)); recurs--; } } void branche(etat *n){ int i,j; for(i=0;i<recurs;i++) cout<<"|"; cout<<n->getB()<<endl; while(n->getNbFils()==1){ for(i=0;i<recurs;i++) cout<<"|"; cout<<n->getB()<<endl; n=n->getFils(0); } j=n->getNbFils(); if(j>0) for(i=0;i<j;i++) afficheArbre(n->getFils(i)); }
et le fichier objets.hppCode:
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 #include <vector> #include "objets.hpp" using namespace std; etat* etat::getFils(int x){ if(x<fils.size()) return fils[x]; else return 0; } void etat::ajouterFils(){ fils.push_back(new etat); } int etat::getNbFils(){ return fils.size(); } char etat::getB(){ return b; } void etat::setB(char x){ b=x; }
voici le message du compilo:Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #ifndef objets_hpp #define objets_hpp #include <vector> class etat{ private: int numNoeud; etat *echec; bool final; std::vector<etat*>fils; char b; public: etat *getFils(int x); void ajouterFils(); int getNbFils(); char getB(); void setB(char x); }; #endif
Code:
1
2
3 arbre.cpp:11:19: error: variable or field afficheArbre declared void arbre.cpp:11:19: error: etat was not declared in this scope arbre.cpp:11:25: error: n was not declared in this scope