Category : deep-copy

Is there a way of passing the ownership of a std::string object’s buffer(char*) by return value? I have the following situation: const char* Foo_Exception::what( ) const throw( ) { std::string tempMsg; // temporary string for forming the message which is destructed at the end of scope tempMsg.reserve( 130000 ); tempMsg = "A string literal to ..

Read more

So I have a class Rectangle with an overloaded operator= defined as follows: Rectangle& Rectangle::operator=(Rectangle &rhs) { if (this != &rhs) { m_x = rhs.m_x; m_y = rhs.m_y; m_width = rhs.m_width; m_height = rhs.m_height; m_intersection = rhs.m_intersection; } return *this; } The compiler doesn’t complain so far. But when I attempt to do an assignment ..

Read more

Here is my class class Course { char *Title, *Subject; int Fees, NumberOfQuizzes, NumberOfAssignments; float QuizPercentMarks, AssignmentPercentMarks, ExamPercentMarks; public: Course(); Course(char T[], char S[], int F, int NQ, int NA, float QPM, float APM, float EPM); Course(const Course &Prev); ~Course(); void setTitle(char x[]); char *getTitle(); void setSubject(char x[]); char *getSubject(); void setFees(int x); int getFees(); ..

Read more