class A
{
private:
int AA;
int qq;
string bb;
public:
virtualvoid display()
}
class B : class A
{
private:
int BB;
public:
void display()
}
class C : class A
{
private:
int CC;
public:
void display()
}
when i run the c.display() it will invoke display() from C, am i right to say that?
what if:
1 2 3 4 5 6 7 8 9 10 11
int main()
{
vector <A *> AA(4);
AA[0] = new BB(1,2,3);
AA[1] = new BB(2,3,4);
AA[2] = new CC(3,4,5);
AA[3] = new CC(6,7,8);
for (int i =0; i <4; i++)
AA[i] ->display(); // this.display will call which class display?
}
Why don't you make each display() method print something different, then run your main() above and see what prints? That will tell you which one is being called.