Say:
Apple is derived from a base Fruit Class, then there is a class ApplePicker derived from a base FruitPicker class.
The ApplePicker class has vector<Apple> appleList
, the Fruit picker class has a pointer to a vector<Fruit>
i.e. vector<fruit>* fruitList
.
I need to be able to set the vector to this pointer, so abstract methods can be run in the fruit picker class(as they only are concerned with the fruit members). But I am having trouble setting this, when I tried to do this:
this->fruitList = &(this->AppleList);
It gives me the error cannot convert to vector<Apple> to vector<Fruit>
. I tried static cast and it gave me the same error. I did a similar thing to a non-vector base class and derived class and it was fine.
I am new to C++, and I am using it on Android via NDK.
So is what I am trying to do impossible and I have to use a vector of pointers like vector<Fruit*>
.