Reputation: 5
just want to know to initialize the vector with class pointe
# include <animation> // a class
std::vector<animation*> animlist;
animlist = new std::vector<animtion*>();
but it shows error "error C2678"
Upvotes: 0
Views: 181
Reputation: 1
you don't initialize a vector. vector is a container. it's good to go when you declare it. you initialize an object, and push it to the container.
Upvotes: 0
Reputation: 227608
Your vector is not a pointer, and it is already initialized here:
std::vector<animation*> animlist; // size 0 vector of animation pointers
What you do in the next line is to attempt to assign a pointer to an std::vector<animaiton*>
to animlist
. This doesn't work because a vector does not have an assignment operator that takes a pointer to a vector of the same type.
Upvotes: 3