[c++] operator+
Résolu/Fermé
jacinthe87
Messages postés
194
Date d'inscription
mercredi 4 février 2009
Statut
Membre
Dernière intervention
15 juillet 2010
-
2 mars 2009 à 21:21
loupius - 2 mars 2009 à 21:33
loupius - 2 mars 2009 à 21:33
1 réponse
Je crois qu'il y a une erreur:
Personnellement, j'aurais écrit:
for(int j=0;j<a.longueur;j++) c.mot[j+a.longueur+1]=a.mot[j];ce serait plutôt: c.mot[j+longueur+1]=a.mot[j];
Personnellement, j'aurais écrit:
Chaine Chaine::operator+(const Chaine & a) { Chaine c; c.longueur=longueur+a.longueur; c.mot=new char[c.longueur]; int i, j; for (i=0; i<longueur; i++) c.mot[i] = mot[i]; for (j=0; j<a.longueur; j++) c.mot[i + j] = a.mot[j]; return c; }