468,496 Members | 1,828 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,496 developers. It's quick & easy.

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

Dec 21 '07 #1
0 739

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Ryan Faulkner | last post: by
24 posts views Thread by Brad Marts | last post: by
2 posts views Thread by sam++ | last post: by
8 posts views Thread by Zheng Da | last post: by
7 posts views Thread by dc | last post: by
7 posts views Thread by Markus Svilans | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.