I have a question about multiple inheritance of protected function and polymorphism. It's quite hard to describe it so I hope it will be clear enough.
Say I have three classes:
class baseClass
{
protected:
virtual int function() = 0;
};
class derived_A:public baseClass
{
int function()
{
//implementation 1
};
};
class derived_B:public baseClass
{
int function()
{
//implementation 2
};
};
class derived_C:public derived_A, public derived_B
{
baseClass ** p_arr; //array of pointers of baseClass kind (polymorphism)
int x=0;
for (int i=0; i<arraySize; i++) // array size = many classes like derived_A, derived_B...
{
x = p_arr[i]->function(); //I already have function that builds this array
//it is not the question so I didn't put it here.
// process x
}
};
Finally my question is - how can I access that "protected" function()
from derived_C
class (inside the for loop)?
I am a bit confused... and will be happy for explanation.
Thanks.