Click here to Skip to main content
15,894,337 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: OnMouseMove Flags Pin
ashukasama31-Dec-07 4:42
ashukasama31-Dec-07 4:42 
GeneralRe: OnMouseMove Flags Pin
Hakan Bulut31-Dec-07 7:38
Hakan Bulut31-Dec-07 7:38 
GeneralSimple C++ Inheritance and Performance Pin
Lea Hayes31-Dec-07 2:50
Lea Hayes31-Dec-07 2:50 
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 
I should learn to read the whole message Blush | :O

Also do overloaded methods cause performance differences?

Well, a normal non-virtual function call has the normal overhead of a, well, normal function call. That is, the arguments are pushed to the stack, the return address is pushed to the stack, etc.

(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
<br />
Derived x;<br />
x.bar(); // x is a derived -- call Derived::bar() directly<br />
<br />
Base *x;<br />
x->foo(); // is x a Base or a Derived? use the function pointer to be sure<br />


If you really think it would make a difference, try it both with virtual and with non-virtual and see what happens. (And let us known what the result was Wink | ;-) )

Florin Crisan

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 
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 

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.