C
cyrusNew
Hi,
I need help to resolve confusion on following example :
class A {
public:
virtual void GetName() = 0;
};
class B : public A {
public:
void GetName() { cout << "B"; }
};
B b;
A* pA = &b;
pA->GetName();
I think this is correct code, but I dont quite understand whats happening
behind it. I mean is pointer pA just equal to B's vptr and if so then does
it require some special sorting of elements of vtbl, like first comes A
virtual methods then B's virtual methods.
Thanks,
I need help to resolve confusion on following example :
class A {
public:
virtual void GetName() = 0;
};
class B : public A {
public:
void GetName() { cout << "B"; }
};
B b;
A* pA = &b;
pA->GetName();
I think this is correct code, but I dont quite understand whats happening
behind it. I mean is pointer pA just equal to B's vptr and if so then does
it require some special sorting of elements of vtbl, like first comes A
virtual methods then B's virtual methods.
Thanks,