Salut,
Je viens de lire plusieurs forums pour faire de la compilation séparée avec devC++ mais je n'ai pas réussi avec mon prog.
Voila, j'ai 3 fichiers : main.cpp, point.cpp et point.hpp
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 /*********** main.cpp **************/ #include <cstdlib> #include <iostream> #include "point.hpp" #include "point.cpp" using namespace std; int main(int argc, char *argv[]) { point a(5,2); a.affiche(); a.deplace(-2, 4); a.affiche(); point b(1, -1); b.affiche(); system("PAUSE"); return EXIT_SUCCESS; }
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 /*********** point.cpp **************/ #include <iostream> #include "point.hpp" // pour introduire les déclarations de la classe point using namespace std; // Définition des fonctions memebres de la classe point point::point(int abs, int ord) { x = abs; y = ord; } void point::deplace (int dx, int dy) { x = x + dx; y = y + dy; } void point::affiche() { cout<<"Je suis en"<< x<<" "<<y<<"\n"; }Voici les erreurs obtenues à la compilation :
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 /*********** point.hpp **************/ #ifndef POINT_H #define POINT_H // déclaration de la classe point class point { private : int x; // déclaration des membres privés int y; public : //déclaration des membres publics point (int abs, int ord); //constructeur void deplace (int dx, int dy); void affiche(); }; #endif
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 multiple definition of 'point::point(int,int)' first defined here multiple definition of 'point::point(int,int)' first defined here multiple definition of 'point::deplace(int,int)' first defined here multiple definition of 'point::affiche(int,int)' first defined here ld returned 1 exit status [build Error]
Partager