S
shanemh
I'm starting out with c++ and for some reason I cant get my brain
around this one:
If I have the following:
void Foo (someClass& x)
{}
int Main (void)
{
Foo(*(new someClass));
}
Is the memory allocated for the 'new someClass' that is passed to Foo,
automatically deleted, or must it be deleted using 'delete'? If so, how
given that the new someClass is never actually assigned to a pointer?
Or, is it assigned to x... i'm not sure....i think i might be missing
something here in the way c++ treats this kind of thing.
Thanks
around this one:
If I have the following:
void Foo (someClass& x)
{}
int Main (void)
{
Foo(*(new someClass));
}
Is the memory allocated for the 'new someClass' that is passed to Foo,
automatically deleted, or must it be deleted using 'delete'? If so, how
given that the new someClass is never actually assigned to a pointer?
Or, is it assigned to x... i'm not sure....i think i might be missing
something here in the way c++ treats this kind of thing.
Thanks