Is this a memory leak? If so, what would be the best way to work around it?
What happens to that class instantiated in the [tt]getAClass[/tt] function? Once [tt]func[/tt] returns there are no more pointers to this class. Will it be automatically deleted because its an anonymous variable (I think that’s the correct term, anyway)? Or is it just hanging out in the heap waiting for the program to end? Thanks for your help in clearing up this matter.Code:#include "myclass.h" void func (MyClass *mc){ // do something with the class } MyClass *getAClass (){ MyClass *c = new MyClass (); // Do some stuff here return c; } int main (){ func (getAClass()); return 0; }


Reply With Quote
Bookmarks