Reference Instantiation/Scope
Good Evening,
A quick question if I may...
If a method is declared and implemented as below:
1 2 3 4
|
static foo& foo::bar() const
{
return new foo();
}
|
and then used as this:
1 2 3 4 5
|
if (something)
{
foo& f = foo::bar();
// etc...
}
|
will the memory allocated in bar() be cleaned up when the reference goes out of scope or do I manually need to free it?
Kind Regards,
Phil.
Every new needs a delete.
Topic archived. No new replies allowed.