Which (virtual) function from which class is called?



 DEVELOP > c-Plus-Plus > Which (virtual) function from which class is called?

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1
Topic: DEVELOP > c-Plus-Plus
User: "Mark Sullivan"
Date: 21 Dec 2007 02:36:27 AM
Object: Which (virtual) function from which class is called?
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
.


  Page 1 of 1


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER