Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Base
- { virtual void foo(); };
- struct D1 : Base
- { virtual void foo(); };
- struct D2 : D1
- { void foo(); };
- D2 instance;
- D1* d1ptr = &instance;
- Base* baseptr = &instance;
- //normal function call to "D2::foo()", no dynamic dispatch.
- instance.foo();
- //virtual function call to "D2::foo()", one dynamic dispatch.
- d1ptr.foo();
- //virtual function call to "D2::foo()", does this incur additional
- //..overhead compared to "d1ptr.foo()"?
- baseptr.foo();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement