Hi! First of all I want to wish you a Happy new year! :)
First of all you need to know that i am new to C++, and i apologize for the things you are going to see... :P I am working on a project and i have some runtime errors..
I have a class,named Fish.
and i create new objects of this class in the vector.
--->
1 2
std::vector<Fish*> f;
f.push_back(new Fish);
I think so far is ok.. But it shows a runtime error, after i delete
many objects:
Yes; don't use pointers. You will find your life much easier if you only use pointers when they are more convenient. In this case they are less convenient, so don't use them. ;)
Bluecoder, what if they want to only remove a specific fish from the vector? The task becomes much simpler without pointers because you don't have to worry about deleteing what they refer to.
If you have a vector of Fish like std::vector<Fish>, the destructors of objects will be automatically called when you erase them from the vector so you don't need pointers.
I have my doubts that the problem is really solved.
While using pointers might have been a bad idea, the code you used was correct.
So the actual problem is most likely still present, just hidden for the moment.