I need someone with more of a clue than I have to tell me if this code snippet shows a memory leak.
std::list< MyClass > myList;
void myFunc ( std::list< MyClass > &myList, int numObjects )
MyClass * myObj;
for ( int i = 0; i < numObjects; ++i )
myObj = new MyClass();
myList.push_back( *myObj );
I have searched online trying to find out if the STL list makes a copy of the object when it's pushed onto the list, which in my mind would definitely cause a leak, or if it will push the actual object.
I know that I can change the type of data in the list to pointers to avoid this, but I want to know what is going on in this example.
Many thanks in advance for your help!