Thanks for the quick response :)
I figured it would happen as there was an uneven number of contructions and destructions (see the output: comment), but I had to make sure. I will return a pointer as usual instead :)
My question is simply, will this lead to memory leaks with any otherwise perfect class) or does the compiler know when the newly created variable (created with new but returned as a reference (not a pointer)) will go out of scope? Thanks a lot - Joakim.
#include <iostream>
class Foo
{
public...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.