Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
3778 connectés 

 


Dernière réponse
Sujet : pb de linkage en C++ sous visual ki marche sous mandrake HELP !!!
ramirez voila j'ai pondu ce code sous visual :  
 
//programme principal
 
#include <string.h>
#include <iostream.h>
 
#include "data.cpp"
 
 
 
int main(void){
 
 data object;
 
 object.set_x(5);
 object.set_y(7.5);
 object.display();
 
 cout << "x = " << object.get_x() << "y = " << object.get_y() << endl;
 
 return 0;
}
 
 
//fichier data.cpp
 
#include <iostream.h>
 
class data {
 private :
  int x;
  float y;
 
 public :
  void set_x(int a);
  void set_y(float b);
  int get_x(void);
  float get_y(void);
  void display(void);
   
};
 
void data::set_x(int a){
  x = a;
}
void data::set_y(float b){
   y = b;
}
int data::get_x(void){
 return x;
}
float data::get_y(void){
 return y;
}
void data::display(){
 cout << "x: " << x << endl;
 cout << "y: " << y << endl;
}
 
la compilation passe sous visual mais j'ai ce message au moment de l'edition de liens :  
data.obj : error LNK2005: "public: void __thiscall data::set_x(int)" (?set_x@data@@QAEXH@Z) already defined in appli.obj
 :cry:  
et pourtant ca passe sous linux sans pb  :love:  
 
qqu'un saurait-il ce ki se passe...
je perd mon latin !!!
et le peut de C++ que j'aie !!!  
 :fou:

Votre réponse
Nom d'utilisateur    Pour poster, vous devez être inscrit sur ce forum .... si ce n'est pas le cas, cliquez ici !
Le ton de votre message                        
                       
Votre réponse


[b][i][u][strike][spoiler][fixed][cpp][url][email][img][*]   
 
   [quote]
 

Options

 
Vous avez perdu votre mot de passe ?


Vue Rapide de la discussion
ramirez voila j'ai pondu ce code sous visual :  
 
//programme principal
 
#include <string.h>
#include <iostream.h>
 
#include "data.cpp"
 
 
 
int main(void){
 
 data object;
 
 object.set_x(5);
 object.set_y(7.5);
 object.display();
 
 cout << "x = " << object.get_x() << "y = " << object.get_y() << endl;
 
 return 0;
}
 
 
//fichier data.cpp
 
#include <iostream.h>
 
class data {
 private :
  int x;
  float y;
 
 public :
  void set_x(int a);
  void set_y(float b);
  int get_x(void);
  float get_y(void);
  void display(void);
   
};
 
void data::set_x(int a){
  x = a;
}
void data::set_y(float b){
   y = b;
}
int data::get_x(void){
 return x;
}
float data::get_y(void){
 return y;
}
void data::display(){
 cout << "x: " << x << endl;
 cout << "y: " << y << endl;
}
 
la compilation passe sous visual mais j'ai ce message au moment de l'edition de liens :  
data.obj : error LNK2005: "public: void __thiscall data::set_x(int)" (?set_x@data@@QAEXH@Z) already defined in appli.obj
 :cry:  
et pourtant ca passe sous linux sans pb  :love:  
 
qqu'un saurait-il ce ki se passe...
je perd mon latin !!!
et le peut de C++ que j'aie !!!  
 :fou:

Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)