Im getting a warning when I compile my code.. The warning is: reference to local variable 'str' returned [enabled by default] I don't whats the problem or what I'm doing wrong.. This is my code...
MyString& operator+(MyString &a){
char *tmp=new char[strlen(szArr)+strlen(a.szArr)+1];
strcpy(tmp, szArr);
strcat(tmp, a.szArr);
MyString str(tmp);
delete tmp;
return str;
}
MyString& operator+(char *s){
if(s)
return *this;
char *tmp=new char[strlen(szArr)+strlen(s)+1];
strcpy(tmp, szArr);
strcat(tmp, s);
MyString str(tmp);
delete tmp;
return str;
}
In both Im getting this warning.. I don't know why is complaining that Im returning the object..