Connecting Tech Pros Worldwide Forums | Help | Site Map

Which (virtual) function from which class is called?

Mark Sullivan
Guest
 
Posts: n/a
#1: Dec 21 '07
Assume I have the following code structure:

class A .... {
....
f() { ..... }
virtual vf() { ..... } }


class B .... {
....
f() { ..... }
virtual vf() { ..... } }

main () {

A a;
B b;

A *pa = new B();
B *pb = new A();

pa->f();
pb->f();
pa->vf();
pb->vf();
.....

}

Which function is called in the four cases above ?

Are all calls possible or are they (at least some of them) already rejected during compilation?

Mark


Closed Thread