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

C / C++ / MFC

 
AnswerRe: GetWindow() Pin
Maximilien28-Jul-10 4:48
Maximilien28-Jul-10 4:48 
GeneralRe: GetWindow() Pin
Caslen28-Jul-10 5:27
Caslen28-Jul-10 5:27 
Questionswitch by type_id (using RTTI) Pin
sashoalm28-Jul-10 1:41
sashoalm28-Jul-10 1:41 
AnswerRe: switch by type_id (using RTTI) Pin
Cool_Dev28-Jul-10 2:13
Cool_Dev28-Jul-10 2:13 
AnswerRe: switch by type_id (using RTTI) PinPopular
Cedric Moonen28-Jul-10 2:15
Cedric Moonen28-Jul-10 2:15 
GeneralRe: switch by type_id (using RTTI) Pin
sashoalm28-Jul-10 2:40
sashoalm28-Jul-10 2:40 
GeneralRe: switch by type_id (using RTTI) Pin
Cedric Moonen28-Jul-10 3:00
Cedric Moonen28-Jul-10 3:00 
AnswerRe: switch by type_id (using RTTI) Pin
Aescleal28-Jul-10 4:30
Aescleal28-Jul-10 4:30 
Quick Question: What does switching on a type mean... especially if you're dynamically casting the result?

Answer: It means you're missing a virtual function!

So don't mess about with switches and casting, add a virtual function to the base class. This will give you three benefits:

- SPEEEEED - a virtual function call will always as fast or faster than a switch on a type_id

- It makes your code a lot easier to read. Your switch/if/then else is replaced by 1 line, yep

- It makes your code a lot easier to extend. If/when you add a new derived class you just have to implement the derived class, you don't have to mess about with the client code.

SO... Just say no to switching on type_id. You know it makes sense.

Cheers,

Ash
GeneralRe: switch by type_id (using RTTI) Pin
Cedric Moonen28-Jul-10 8:54
Cedric Moonen28-Jul-10 8:54 
QuestionEnter button not working on CBitmapButton. Pin
Le@rner28-Jul-10 1:34
Le@rner28-Jul-10 1:34 
AnswerRe: Enter button not working on CBitmapButton. Pin
ARopo28-Jul-10 2:20
ARopo28-Jul-10 2:20 
GeneralRe: Enter button not working on CBitmapButton. Pin
Le@rner28-Jul-10 2:30
Le@rner28-Jul-10 2:30 
QuestionAdding combo box to list control Pin
Sakhalean28-Jul-10 1:16
Sakhalean28-Jul-10 1:16 
AnswerRe: Adding combo box to list control Pin
Cool_Dev28-Jul-10 1:22
Cool_Dev28-Jul-10 1:22 
AnswerRe: Adding combo box to list control Pin
David Crow28-Jul-10 3:09
David Crow28-Jul-10 3:09 
AnswerRe: Adding combo box to list control Pin
Rolf Kristensen29-Jul-10 2:29
Rolf Kristensen29-Jul-10 2:29 
QuestionPassing Variable between Files Pin
T.RATHA KRISHNAN28-Jul-10 0:30
T.RATHA KRISHNAN28-Jul-10 0:30 
AnswerRe: Passing Variable between Files Pin
Cool_Dev28-Jul-10 1:10
Cool_Dev28-Jul-10 1:10 
AnswerRe: Passing Variable between Files Pin
Aescleal28-Jul-10 1:27
Aescleal28-Jul-10 1:27 
QuestionScanf problem Pin
sagargulhane27-Jul-10 21:32
sagargulhane27-Jul-10 21:32 
AnswerRe: Scanf problem [modified] Pin
Aescleal27-Jul-10 21:49
Aescleal27-Jul-10 21:49 
GeneralRe: Scanf problem Pin
sagargulhane28-Jul-10 23:23
sagargulhane28-Jul-10 23:23 
AnswerRe: Scanf problem Pin
«_Superman_»27-Jul-10 22:31
professional«_Superman_»27-Jul-10 22:31 
Questionpdb VC++ Pin
VVVimal27-Jul-10 19:47
VVVimal27-Jul-10 19:47 
AnswerRe: pdb VC++ Pin
Sauro Viti27-Jul-10 20:52
professionalSauro Viti27-Jul-10 20:52 

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.