Witam.
Czemu moje operatory + nie chcą zwracać obiektu utworzonego w ich ciele ? Debugger przechodzi przez wszystkie linie tych metod a program sypie się przy próbie zwrócenia obiektu.
Stringw Stringw::operator+(const Stringw &st)
{
Stringw sum;
sum.str = new char[len + st.len +1];
strcpy(sum.str, str);
strcat(sum.str, st.str);
sum.len = len + st.len;
return sum;
}
//ta funkcja jest zaprzyjaźniona z klasą
Stringw operator+( const char*s, const Stringw &st)
{
Stringw sum;
sum.str = new char[strlen(s) + st.len + 1];
strcpy(sum.str, s);
strcat(sum.str, st.str);
sum.len = strlen(s) + st.len;
return sum;
}
Stringw Stringw::operator+(const char* s)
{
Stringw sum;
sum.str = new char[len + strlen(s) + 1];
sum.len = len + strlen(s);
strcpy(sum.str, str);
strcat(sum.str,s);
return sum;
}