perlperl
asked on
Does this leak memory
struct some_struct {
}
std::vector<some_struct *> list_of_struct;
list_of_struct.push_back(new some_struct());
some_struct* remove_first_member() {
std::vector<some_struct *>::iterator it( list_of_struct.begin());
some_struct *temp = *it;
list_of_struct.erase(it);
return temp;
}
// somewhere in main I am calling
remove_first_member(); // There is no lvalue even though the function returns pointer
// to some_struct
Will this leak memory?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
some_struct* temp = remove_first_member();
delete temp;