une fonction d'affichage à rajouter
bonjour
j'ia un code qui compile sous visual c++6.0 mais ne compile pas sur devc++.
je voudrai éviter ces erreurs sur devc++, pourriez vous m'aider?
(les ptis warning ou erreurs peuvent qq fois montrer qu'un code est peu rigoureux ou qu'il y a un risque qq part donc je voudrai juste éviter les messages d'erreurs).
merci
voilà mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include <string.h> // strcpy(); strlen();
#include <conio.h> // getch();
#include <iostream> // cout et cin
using namespace std;
class String
{
// private :
int nbr;
char *ptr;
public:
String (char[]);
String (char);
~String();
String& operator=(const String &);
String(const String &);
String plus (const String &);
};
String String::plus(const String &s)
{
char *chaine = new char[nbr+s.nbr-1];
for(int i=0;i<nbr-1;i++) // strcpy(chaine,ptr); l66
chaine[i]=ptr[i];
for(i=nbr-1;i<nbr+s.nbr-1;i++) // strcat(chaine,s.ptr); l68
chaine[i]=s.ptr[i-nbr+1];
String resultat(chaine);
delete chaine;
return (resultat);
}
void main ()
{
String s1("azerty"),s2('q');
String s3=s1.plus(s2);
s3=s1.plus('w');
getch();
} |
les erreurs sont les suivantes :
Code:
1 2 3 4 5 6 7
|
In member function `String String::plus(const String&)':
68: error: name lookup of `i' changed for new ISO `for' scoping
66: error: using obsolete binding at `i'
66: error: At global scope: |
MERCI d'avance.
ps : remplacer par strcpy et ctrcat règle le problème mais comment avec seulement 2 fort j'obtiens 4 erreurs 8O