Click here to Skip to main content
15,888,454 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: VC++ win32 projects Pin
Satish Pai7-Jul-09 2:15
Satish Pai7-Jul-09 2:15 
GeneralRe: VC++ win32 projects Pin
«_Superman_»7-Jul-09 2:21
professional«_Superman_»7-Jul-09 2:21 
GeneralRe: VC++ win32 projects Pin
Satish Pai7-Jul-09 2:24
Satish Pai7-Jul-09 2:24 
Questionwhen to use switch-case and when to use if-else Pin
pandit847-Jul-09 0:10
pandit847-Jul-09 0:10 
AnswerRe: when to use switch-case and when to use if-else Pin
Rajesh R Subramanian7-Jul-09 0:28
professionalRajesh R Subramanian7-Jul-09 0:28 
AnswerRe: when to use switch-case and when to use if-else Pin
Chandrasekharan P7-Jul-09 0:32
Chandrasekharan P7-Jul-09 0:32 
AnswerRe: when to use switch-case and when to use if-else Pin
chandu0047-Jul-09 0:33
chandu0047-Jul-09 0:33 
AnswerRe: when to use switch-case and when to use if-else Pin
Roger Stoltz7-Jul-09 0:33
Roger Stoltz7-Jul-09 0:33 
One rule is of course the fact that switch-case needs to compare with constant values; you cannot put a variable in a case statement.

If you have constant values to compare with, and the range is rather small, the compiler is often able to generate a jump table which is faster in comparison.
However, if you have a large range of values and/or if they are widely spread, many compilers would generate the code as if you would have used the if-else solution. To create a jump table in such case would be far too complex to be built with a generic algorithm as a compiler would provide.

If you opt for the if-else solution, put the condition most likely to happen at the top, otherwise multiple conditions have to be evaluated before the right one is found for the major part of the calls.

There's some interesting notes here[^] as well.


"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown


AnswerRe: when to use switch-case and when to use if-else Pin
_AnsHUMAN_ 7-Jul-09 0:36
_AnsHUMAN_ 7-Jul-09 0:36 
GeneralRe: when to use switch-case and when to use if-else Pin
pandit847-Jul-09 0:41
pandit847-Jul-09 0:41 
AnswerRe: when to use switch-case and when to use if-else Pin
Rozis7-Jul-09 2:09
Rozis7-Jul-09 2:09 
QuestionGenerating "msoult.h" from "msoutl.olb" using VS2005 Pin
eight6-Jul-09 22:25
eight6-Jul-09 22:25 
AnswerRe: Generating "msoult.h" from "msoutl.olb" using VS2005 Pin
Stuart Dootson6-Jul-09 23:11
professionalStuart Dootson6-Jul-09 23:11 
QuestionCString to char Pin
MsmVc6-Jul-09 22:01
MsmVc6-Jul-09 22:01 
AnswerRe: CString to char Pin
Cedric Moonen6-Jul-09 22:08
Cedric Moonen6-Jul-09 22:08 
GeneralRe: CString to char Pin
MsmVc6-Jul-09 22:17
MsmVc6-Jul-09 22:17 
GeneralRe: CString to char Pin
Rajesh R Subramanian6-Jul-09 22:21
professionalRajesh R Subramanian6-Jul-09 22:21 
GeneralRe: CString to char Pin
Cedric Moonen6-Jul-09 22:22
Cedric Moonen6-Jul-09 22:22 
GeneralRe: CString to char Pin
David Crow7-Jul-09 3:18
David Crow7-Jul-09 3:18 
GeneralRe: CString to char Pin
Michael Schubert7-Jul-09 3:35
Michael Schubert7-Jul-09 3:35 
GeneralRe: CString to char Pin
Rajesh R Subramanian7-Jul-09 7:38
professionalRajesh R Subramanian7-Jul-09 7:38 
AnswerRe: CString to char Pin
Rage6-Jul-09 22:09
professionalRage6-Jul-09 22:09 
AnswerRe: CString to char Pin
Rajesh R Subramanian6-Jul-09 22:11
professionalRajesh R Subramanian6-Jul-09 22:11 
GeneralRe: CString to char Pin
Cedric Moonen6-Jul-09 22:14
Cedric Moonen6-Jul-09 22:14 
GeneralRe: CString to char Pin
Rajesh R Subramanian6-Jul-09 22:20
professionalRajesh R Subramanian6-Jul-09 22:20 

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.