returning a temporary class object
i have a class that returns a temporary object when i overload the addition operator
here is the sample code
Code:
CBox operator+(const CBox& aBox) // CBox is a class
{
float h = this->m_height + aBox.m_height;
float b = this->m_breadth + aBox.m_breath;
float l = this->m_length + aBox.m_length;
return CBox(h, b, l);
// returning a temporary CBox object
}
help is appreciated...thanks...this is always puzzles me because i thought objects cease to exist after they go out of scope...