how to access child instances in a vector in c++
- by tsubasa
I have a parent class and child class (inherited from parent).
In the child class, I have a member function named function_blah();
I used vector<parent*> A to store 5 parent instances, 3 child instances. So the total number of elements in the vector is 8.
I can easily access to member functions of element A[0] to A[4], which are parent instances.
But whenever I try to have access to member functions of element A[5] to A[7], the compiler complains that class parent has no member named 'function_blah'
The way I access to elements is using index. e.x A[i] with i = 0..7. Is it correct? if not, how?