Bonjour à tous
je viens de me mettre au C++ et après mon premier programme j'ai un bug a la compilation (je pense que le bug n'est pas du au code mais a un problème dû à mon ordi, je tourne sous Mac OS X 10.14)
voici la capture d'écran du problème
Pièce jointe 420374
je mets aussi le copier/coller du message d'erreur au cas où :
Undefined symbols for architecture x86_64: "Ennemi::est_vivant()", referenced from: _main in main-b1bd6a.o "Ennemi::get_x()", referenced from: _main in main-b1bd6a.o "Ennemi::get_y()", referenced from: _main in main-b1bd6a.o "Ennemi::get_score()", referenced from: _main in main-b1bd6a.o "Ennemi::Ennemi(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int, int)", referenced from: _main in main-b1bd6a.o "Ennemi::~Ennemi()", referenced from: _main in main-b1bd6a.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
je poste aussi le contenu des fichiers utilisés ici :
Main.cpp :
Ennemi.hCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include <iostream> #include <stdio.h> #include <string.h> #include "Ennemi.h" using namespace std; int main(){ cout << "Hello World !!" << endl; Ennemi e ("Hello", 1, 3); cout << "x : "; cout << e.get_x() << endl; cout << "y : "; cout << e.get_y() << endl; cout << "vivant : "; cout << e.est_vivant() << endl; cout << "score : "; cout << e.get_score() << endl; return 0; }
Ennemi.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 #ifndef DEF_ENNEMI #define DEF_ENNEMI #include <iostream> #include <stdio.h> #include <math.h> #include <string.h> using namespace std; class Ennemi { public : Ennemi (); Ennemi (string s); Ennemi (string s, int x, int y); bool est_vivant (); void generation (string s, int L, int H); void generation (int L, int H); int get_x (); int get_y (); char get_symbole (); int get_score (); void set_mort (); // bool toucher_par_oiseau (Oiseau &o); ~Ennemi (); private : int x; int y; bool vivant; string type; int score; }; #endif
Code:
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 #include "Ennemi.h" using namespace std; Ennemi (){ Ennemi e; e.x = 0; e.y = 0; e.vivant = 1; e.type = " "; e.score = 0; return e; } Ennemi (string s){ Ennemi e; e.x = 0; e.y = 0; e.vivant = 1; e.type = s; e.score = 0; return e; } Ennemi (string s, int x, int y){ Ennemi e; e.x = x; e.y = y; e.vivant = 1; e.type = s; e.score = 0; return e; } bool est_vivant (){ return this.vivant; } void generation (string s, int L, int H){ } void generation (int L, int H){ } int get_x (){ return this.x; } int get_y (){ return this.y; } char get_symbole (){ } int get_score (){ return this.score; } void set_mort (){ this.vivant = 0; } // bool Ennemi::toucher_par_oiseau (Oiseau &o){ // } ~Ennemi (){ }
je vous remercie d'avance de votre aide