CAbout CAbout::operator+(const CAbout& str) { CAbout dopstr; dopstr.m_length = this->m_length + str.m_length - 1; dopstr.m_strok = new char[dopstr.m_length]; for (size_t i{0}; i < this->m_length; i++) { *(dopstr.m_strok + i) = *(this->m_strok + i); } for (size_t i{ 0 }; i < str.m_length + 1; i++) { dopstr.m_strok[i + this->m_length] = str.m_strok[i]; } return dopstr; } The class itself looks like a trace. way
class CAbout { public: CAbout(const char* str = "Standart str"); CAbout(const CAbout& str); ~CAbout(); CAbout& operator=(const CAbout& str); CAbout operator+(const CAbout& str); void show(); private: char* m_strok; size_t m_length; }; Interested in the functions of the operator +, all other functions work well. Even not so much interested in how to write the correct working code, but why the first for loop in the function of the + operator works well, and the second cycle passes, but does not change anything. The string of class dopstr takes the value this-> m_strok in the first loop and does not change further. What is the problem ?