Click here to Skip to main content
15,893,814 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Simple C++ Inheritance and Performance Pin
Florin Crişan31-Dec-07 3:14
Florin Crişan31-Dec-07 3:14 
GeneralRe: Simple C++ Inheritance and Performance Pin
Florin Crişan31-Dec-07 3:17
Florin Crişan31-Dec-07 3:17 
GeneralRe: Simple C++ Inheritance and Performance Pin
Lea Hayes31-Dec-07 4:23
Lea Hayes31-Dec-07 4:23 
GeneralRe: Simple C++ Inheritance and Performance Pin
CPallini31-Dec-07 3:25
mveCPallini31-Dec-07 3:25 
GeneralRe: Simple C++ Inheritance and Performance [modified] Pin
Florin Crişan31-Dec-07 3:28
Florin Crişan31-Dec-07 3:28 
GeneralWhat other people say about this: Pin
Florin Crişan31-Dec-07 3:35
Florin Crişan31-Dec-07 3:35 
JokeHappy New Year! Pin
Florin Crişan31-Dec-07 3:40
Florin Crişan31-Dec-07 3:40 
GeneralRe: Simple C++ Inheritance and Performance Pin
CPallini31-Dec-07 3:42
mveCPallini31-Dec-07 3:42 
Florin Crisan wrote:
Also do overloaded methods cause performance differences?



Florin Crisan wrote:
(As far as I know) If you have a polymorphic object, in most implementations it keeps a (hidden) pointer to a table of function pointers (known as 'vtable'). So, before making the call, the pointer to the vtable and then the one to the function would have to be de-referenced. (I really don't know how expensive that is; it may be significant on some systems, but probably nothing significant for normal use).

However, if the compiler is able to tell the exact type of the object, it won't need to call the function virtually.

For example

Derived x;
x.bar(); // x is a derived -- call Derived::bar() directly



Base *x;
x->foo(); // is x a Base or a Derived? use the function pointer to be sure


Method overload and method override are two quite distinct concepts, he asked for the former, you're talking about the latter.




Florin Crisan wrote:
Derived x;
x.bar(); // x is a derived -- call Derived::bar() directly

Base *x;
x->foo(); // is x a Base or a Derived? use the function pointer to be sure


AFAIK method invocation is always done via vtables.

Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

[my articles]


GeneralRe: Simple C++ Inheritance and Performance Pin
Florin Crişan31-Dec-07 3:46
Florin Crişan31-Dec-07 3:46 
GeneralRe: Simple C++ Inheritance and Performance Pin
CPallini31-Dec-07 4:09
mveCPallini31-Dec-07 4:09 
GeneralRe: Simple C++ Inheritance and Performance Pin
Lea Hayes31-Dec-07 4:27
Lea Hayes31-Dec-07 4:27 
Questionhow can i convert a BYTE value into CString Pin
rajneshmalik31-Dec-07 2:18
rajneshmalik31-Dec-07 2:18 
AnswerRe: how can i convert a BYTE value into CString Pin
Florin Crişan31-Dec-07 2:50
Florin Crişan31-Dec-07 2:50 
GeneralRe: how can i convert a BYTE value into CString Pin
Florin Crişan31-Dec-07 3:04
Florin Crişan31-Dec-07 3:04 
AnswerRe: how can i convert a BYTE value into CString [modified] Pin
Nishad S31-Dec-07 2:52
Nishad S31-Dec-07 2:52 
AnswerRe: how can i convert a BYTE value into CString Pin
Lea Hayes31-Dec-07 3:03
Lea Hayes31-Dec-07 3:03 
QuestionRe: how can i convert a BYTE value into CString Pin
Florin Crişan31-Dec-07 3:08
Florin Crişan31-Dec-07 3:08 
Questiongrowing virtual memory Pin
canercaner30-Dec-07 23:25
canercaner30-Dec-07 23:25 
GeneralRe: growing virtual memory Pin
CPallini30-Dec-07 23:35
mveCPallini30-Dec-07 23:35 
GeneralRe: growing virtual memory [modified] Pin
canercaner31-Dec-07 2:51
canercaner31-Dec-07 2:51 
GeneralRe: growing virtual memory Pin
CPallini31-Dec-07 3:08
mveCPallini31-Dec-07 3:08 
GeneralRe: growing virtual memory Pin
canercaner31-Dec-07 3:58
canercaner31-Dec-07 3:58 
GeneralRe: growing virtual memory Pin
CPallini31-Dec-07 4:07
mveCPallini31-Dec-07 4:07 
QuestionRe: growing virtual memory Pin
bob1697231-Dec-07 3:04
bob1697231-Dec-07 3:04 
GeneralRe: growing virtual memory Pin
canercaner31-Dec-07 4:22
canercaner31-Dec-07 4:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.