In main I want to concatenate two strings
s1=s2+s3; // overloading +,=
my questin concerns the data object that the pointer to char points to using the strcat function. Will this be destroyed when the overload function ends?Code:String & String::operator=(const String & st) { if (this==&st) return *this; delete [] str; len=st.len; str new char[len+1]; strcpy(str,st.str); return *this; } // assign a C string to a String String & String::operator=(const char * s) { delete [] str; len = strlen(s); str=new char[len+1]; strcpy(str,s); return *this; } //concatinate two strings String operator+(const String &str1,const String &str2) { return strcat(str1.str,str2.str); }



LinkBack URL
About LinkBacks


