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

C / C++ / MFC

 
GeneralMessage Closed Pin
28-Jul-10 6:50
nhqlbaislwfiikqraqnm28-Jul-10 6:50 
GeneralRe: C with Visual Studio 2010 Pin
rp_suman28-Jul-10 6:56
rp_suman28-Jul-10 6:56 
GeneralRe: C with Visual Studio 2010 Pin
Cedric Moonen28-Jul-10 8:10
Cedric Moonen28-Jul-10 8:10 
GeneralRe: C with Visual Studio 2010 Pin
rp_suman28-Jul-10 6:45
rp_suman28-Jul-10 6:45 
QuestionGetWindow() Pin
Caslen28-Jul-10 4:25
Caslen28-Jul-10 4:25 
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 
I have multiple derived classes and a function that accepts their (abstract) base ptr.

Right now I have a lot of code like this in my function:

void foo(BaseClass* p)
{
	if (DerivedClass1 *p1 = dynamic_cast<DerivedClass1 *>(p))
	{
             ...;
	}
	else if(DerivedClass2 *p2 = dynamic_cast<DerivedClass2 *>(p))
	{
             ...;
	}
}


I want to replace it with a switch if possible:

switch (p.type_id)
{
case DerivedClass1.type_id: ...; break;
case DerivedClass2.type_id: ...; break;
}


is that possible to do?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal

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

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.