Help !

Résolu
zied9992000 Messages postés 9 Date d'inscription lundi 16 juillet 2007 Statut Membre Dernière intervention 7 mars 2009 - 9 déc. 2008 à 20:36
Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 - 10 déc. 2008 à 02:06
salu les amis !, svp est ce qu'il ya une faute ici ???
il ma retourne:
9700 parie reel
17890 partie imag
ya t'il 1 autre methode !
#include
class complexe{
public:
int reel, imag;
complexe(int reel=0,int imag=0){};
friend complexe operator+(complexe A,complexe B)
{
return(A.reel+B.reel,A.imag+B.imag);
}
void affiche()
{
cout<<"La Partie Reel est: "<<reel;
cout<<"\nLa Partie Imaginaire est: "<<imag;
}
};

void main(){
complexe z1(5,6),z3(0,0);
z3=z1+z1;
z3.affiche();
}

3 réponses

xmox667 Messages postés 357 Date d'inscription jeudi 8 juin 2006 Statut Membre Dernière intervention 26 décembre 2011 4
9 déc. 2008 à 20:43
Salut,
Le corps de ton constructeur est vide essaye ceci:

complexe(int r=0,int i=0)
{
reel = r;
imag= i;
}

A+
3
zied9992000 Messages postés 9 Date d'inscription lundi 16 juillet 2007 Statut Membre Dernière intervention 7 mars 2009
9 déc. 2008 à 21:05
merci beaucoup xmos667 !
0
Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 41
10 déc. 2008 à 02:06
cppfrance ici  -> http://www.cppfrance.com/
0
Rejoignez-nous