1- Questions en orienté objet
:salut:
Code:
1 2 3 4 5 6 7
| class String{
protected:
char * str;
private:
String copyleft(char * s, int cp);
}; |
Code:
1 2 3 4 5 6 7 8
|
String String::copyleft(char *s,int cp){
int i;
this->str=new char [strlen(s)]+1;
for(i=0;i<cp;i++)this->str[cp]=s[cp];
this->str[i]='\0';
return *this;
} |
Je veux retourner un objet de type String
1- Est-ce que ce n’est pas nécessaire de l’alloue de la mémoire ?
2- Pour retourner un objet est ce qu’on fait : return objet ; ou bien : return * objet ???
:merci: