Possible duplicate:
object pointer vector - how to avoid memory leak?
Hello everybody,
I have the following code,
vector<Student*> vec;
Then sort(vec.begin(), vec.end(), ...)sort the student based on grade.
Here is the question
Since the vector stores pointers, we must later remember that we need to delete it manually. However, we cannot store auto_ptr inside the vector.
Is there a better way to do this? Store smart pointer inside a vector? How to create this smart pointer?
thank
q0987 source
share