M
Mark Sullivan
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
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