First I have a class called Foo and it contains a virtual function int Foo::getId()
I have a typedef: typedef std::vector<Foo*> FooList;
Then I define Foo::FooList *list; and I load up this vector.
I was wondering how I would access getId(). Currently I am using list[a].getId(); but the compiler keep saying error: class std::vector<Foo*, std::allocator<Foo*> > has no member named getId.
Thanks for your help!
You could also do
or
or any combination.
The
listis a pointer, so needs to be dereferenced, as do the pointers it contains. The array operator on a pointer that is not dereferenced will addatolist– making it point to a different location.