There is no point to this, vector has no virtual members. Just make it a member of Horse itself if you really need access to it from that class.
What you probably want is to create a virtual base class animal and inherit from that:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
class Animal
{
public:
virtualvoid Eat();
virtualvoid Move();
//etc.
}
class Horse: public Animal
{
public:
virtualvoid Eat(); //Here you can implement Horse's specific Eating habits
//etc...
}
Vector is a template class, a container of objects the type of which will be determined at compile time. So you can have a vector containing integers (vector<int>), a vector containing animals (vector<animal>), or, in your case, a vector containing pointers to animals.
So, "vector of pointers to animals" is a real class--the template parameter is defined and there is no more uncertainty about it. The class is totally distinct from, for instance, a vector of integers. And vector<animal*> can be extended by inheritance like any other class you create in C++.
In your case, you defined the class horse to extend (derive from, inherit from, become a subclass of) the class "vector of pointers to animals". (Note: it doesn't make sense, but it is syntactically legal.)
"I know inheritance but I don not understand this part" vector<animal*>
You're inheriting from the std::vector, and animal* is the type of object the std::vector will hold. However, do not inherit from a std::vector; its destructor is non-virtual.
In your case, you defined the class horse to extend (derive from, inherit from, become a subclass of) the class "vector of pointers to animals". (Note: it doesn't make sense, but it is syntactically legal.)