Connecting Tech Pros Worldwide Help | Site Map

Which (virtual) function from which class is called?

 
LinkBack Thread Tools Search this Thread
  #1  
Old December 21st, 2007, 07:45 AM
Mark Sullivan
Guest
 
Posts: n/a
Default 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


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.