I should first mention that although I am not an inexperienced programmer, not much of that experience has been with C++. I'm quite comfortable with C memory management. That may explain why I am confused
Code: Select all
Object& CreateObject()
{
Object * obj = new Object(); // created on heap since it will be returned
return *obj; // is memory leaked here?
}
void UseObject()
{
// do both of these cause a leak?
Object obj1 = CreateObject(); // plain old local variable
Object& obj2 = CreateObject() // local reference
}
Anyways, with the number of coders in this forum I thought it would be the perfect place to ask and be sure of the answer
Thanks,
~djc






