I'm creating an animal board game where various animals are placed on the board.
I have an Animal class that is abstract.
I then have a Rabbit and a Turtle class which both derive from Animal.
All information about the animal needs to be stored in a vector of pointers to the Animal object.
One of the things I have to do is initialise the animal vector, which I think I have already done.
1 2 3 4 5 6 7 8 9 10
int main()
{
cout << "Welcome To Animals Life: A Game" << endl;
vector<Animal*> animalList;
animalList.push_back(new Rabbit());
animalList.push_back(new Turtle());
}
All the information for the animals is loaded from a text file into the vector from another method.
My problem is that I'm unable to display the animals from the vector. I have a "displayAllAnimals" method, but whenever I attempt to display them all the values come up as 0. How do I correctly pass the values in the vector to different methods?