Compilation séparée avec devc++
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:
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:
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";
} |
Code:
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 |
Voici les erreurs obtenues à la compilation :
Code:
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] |
problème compilation séparée sous DevC++
Voila à nouveau le même message remis en forme :
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
/*********** main.cpp **************/
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#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;
} |
/*********** point.cpp **************/
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#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";
} |
/*********** point.hpp **************/
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#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 |
Voici les erreurs obtenues à la compilation :
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]