Bonjour,

Je suis débutante en programmation. Je suis en train d'apprendre à coder l'association entre deux classes mais il y a un message d'erreur "Personnage' has not been declared" et "'Personnage' does not name a type" qui apparaissent dans toutes mes tentatives et que je ne sais comment rectifier. L'IDE utilisé est code::blocks 17.12.

Voici les fichiers "Personnage.h" et "Arme"

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
#ifndef ARME_H_INCLUDED
 
#define ARME_H_INCLUDED
 
#include "Personnage.h"
 
class Arme
 
{
 
public:
 
    Arme();
 
    Arme(m_arme, std::string m_nomArme);
 
    void afficherArme();
 
    void attributionAPersonnage (Personnage *a); // pour attribuer l'arme a un personnage
 
private:
 
   int m_arme;
 
    std::string m_nonArme;
 
    Personnage *cePersonnage;
 
};
 
#endif // ARME_H_INCLUDED
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
#ifndef PERSONNAGE_H_INCLUDED
 
#define PERSONNAGE_H_INCLUDED
 
#include "Arme.h"
 
class Personnage
 
{
 
public:
 
    Personnage();
 
    Personnage (m_mana, m_nbreDegats);
 
    void afficherPersonnage();
 
    void initArmeDePersonnage (Arme *b);
 
private:
 
    int m_mana;
 
    int m_nbreDegats:
 
    Arme **uneArme;
 
    vector <Arme*> tabArmeDePersonnage;
 
};
 
#endif // PERSONNAGE_H_INCLUDED
voici les messages d'erreur:

-------------- Build: Debug in open_class_room (compiler: GNU GCC Compiler)-------

mingw32-g++.exe -Wall -fexceptions -g  -c C:\Users\HP\Desktop\CNED\open_class_room\Personnage.cpp -o obj\Debug\Personnage.o
mingw32-g++.exe  -o bin\Debug\open_class_room.exe obj\Debug\Arme.o obj\Debug\main.o obj\Debug\Personnage.o   
In file included from C:\Users\HP\Desktop\CNED\open_class_room\Personnage.h:4:0,
                 from C:\Users\HP\Desktop\CNED\open_class_room\Personnage.cpp:1:
C:\Users\HP\Desktop\CNED\open_class_room\Arme.h:11:16: error: expected ')' before ',' token
     Arme(m_arme, std::string m_nomArme);
                ^
C:\Users\HP\Desktop\CNED\open_class_room\Arme.h:13:34: error: 'Personnage' has not been declared
     void attributionAPersonnage (Personnage *a); // pour attribuer l'arme a un personnage
                                  ^
C:\Users\HP\Desktop\CNED\open_class_room\Arme.h:16:10: error: 'string' in namespace 'std' does not name a type
     std::string m_nonArme;
          ^
C:\Users\HP\Desktop\CNED\open_class_room\Arme.h:17:5: error: 'Personnage' does not name a type
     Personnage *cePersonnage;
     ^
In file included from C:\Users\HP\Desktop\CNED\open_class_room\Personnage.cpp:1:0:
C:\Users\HP\Desktop\CNED\open_class_room\Personnage.h:10:23: error: expected ')' before ',' token
     Personnage (m_mana, m_nbreDegats);
                       ^
C:\Users\HP\Desktop\CNED\open_class_room\Personnage.h:17:10: error: expected primary-expression before '*' token
     Arme *CetArme;
          ^
C:\Users\HP\Desktop\CNED\open_class_room\Personnage.h:17:11: error: 'CetArme' was not declared in this scope
     Arme *CetArme;
Merci d'avance