Click here to Skip to main content
15,891,607 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to block unwanted websites using socket programming? Pin
ArashFar14-Feb-09 7:40
ArashFar14-Feb-09 7:40 
QuestionRead KKEY_CURRENT_USER Registry? Pin
Software200711-Feb-09 4:48
Software200711-Feb-09 4:48 
AnswerRe: Read KKEY_CURRENT_USER Registry? Pin
David Crow11-Feb-09 5:01
David Crow11-Feb-09 5:01 
GeneralRe: Read KKEY_CURRENT_USER Registry? Pin
Software200711-Feb-09 5:06
Software200711-Feb-09 5:06 
GeneralRe: Read KKEY_CURRENT_USER Registry? Pin
led mike11-Feb-09 5:15
led mike11-Feb-09 5:15 
GeneralRe: Read KKEY_CURRENT_USER Registry? Pin
Software200711-Feb-09 5:20
Software200711-Feb-09 5:20 
GeneralRe: Read KKEY_CURRENT_USER Registry? Pin
Software200711-Feb-09 5:59
Software200711-Feb-09 5:59 
QuestionClass wrapper Pin
jung-kreidler11-Feb-09 4:29
jung-kreidler11-Feb-09 4:29 
Hi all,

I've got a small problem with derived classes and a wrapper class. To show you what my problem is, I write down some code. Here's what I do now:

class Base
{
doFunc1();
virtual doFunc2();
}

class Der1 : public Base
{
doFunc2();
}
class Der2 : public Base
{
doFunc2();
}

class Wrap
{
Der1 *d1;
Der2 *d2;
doFunc1();
doFunc2();
}

Wrap::doFunc1()
{
if(somecondition)
d1->doFunc1();
else
d2->doFunc1();
}

Wrap::doFunc2()
{
if(somecondition)
d1->doFunc2();
else
d2->doFunc2();
}

From my program I can call:
Wrap::doFunc1();

Now I want to remove the Wrapper calls and replace them with function pointers like this:
class Wrap
{
Der1 *d1;
Der2 *d2;
(*doFunc1)();
(*doFunc2)();
}

Wrap::Wrap
{
if(somecondition)
this->doFunc1 = &Der1::doFunc1;// causes C2440
this->doFunc2 = &Der1::doFunc2;// causes C2440
else
this->doFunc1 = &Der1::doFunc1;// causes C2440
this->doFunc2 = &Der1::doFunc2;// causes C2440
}

From my program I would like to call:
Wrap::doFunc1();

The line this->doFunc1 = ... causes C2440: type cast: cannot convert from (__thiscall Der1::*)() to (__cdecl*)().

I know that class members are not the same as normal c-functions, this causes the __thiscall to __cdecl error, but I thought that there is some trick to get it to work.
Any ideas?

jung-kreidler
AnswerRe: Class wrapper Pin
«_Superman_»11-Feb-09 15:38
professional«_Superman_»11-Feb-09 15:38 
GeneralRe: Class wrapper Pin
jung-kreidler11-Feb-09 20:15
jung-kreidler11-Feb-09 20:15 
QuestionKeypad Dialog Pin
Reagan Conservative11-Feb-09 3:42
Reagan Conservative11-Feb-09 3:42 
AnswerRe: Keypad Dialog Pin
David Crow11-Feb-09 4:28
David Crow11-Feb-09 4:28 
QuestionUrgent : Dialog box size? Pin
sam_psycho11-Feb-09 1:42
sam_psycho11-Feb-09 1:42 
AnswerRe: Urgent : Dialog box size? Pin
Stuart Dootson11-Feb-09 2:02
professionalStuart Dootson11-Feb-09 2:02 
GeneralRe: Urgent ? Pin
CPallini11-Feb-09 2:20
mveCPallini11-Feb-09 2:20 
GeneralRe: Urgent ? Pin
sam_psycho11-Feb-09 3:24
sam_psycho11-Feb-09 3:24 
JokeRe: Urgent ? Pin
«_Superman_»11-Feb-09 15:43
professional«_Superman_»11-Feb-09 15:43 
QuestionServer/Client Development Pin
raghu valluri11-Feb-09 0:30
raghu valluri11-Feb-09 0:30 
AnswerRe: Server/Client Development Pin
Stuart Dootson11-Feb-09 0:59
professionalStuart Dootson11-Feb-09 0:59 
QuestionChecking ActiveX registration programmatically! Pin
Mohammad Khodaea11-Feb-09 0:27
Mohammad Khodaea11-Feb-09 0:27 
AnswerRe: Checking ActiveX registration programmatically! Pin
_AnsHUMAN_ 11-Feb-09 0:44
_AnsHUMAN_ 11-Feb-09 0:44 
AnswerRe: Checking ActiveX registration programmatically! Pin
Stuart Dootson11-Feb-09 0:53
professionalStuart Dootson11-Feb-09 0:53 
QuestionChild window problem Pin
Abhijit D. Babar11-Feb-09 0:12
Abhijit D. Babar11-Feb-09 0:12 
QuestionHow to build the application in release mode Pin
Member 465174110-Feb-09 23:29
Member 465174110-Feb-09 23:29 
AnswerRe: How to build the application in release mode Pin
Cedric Moonen10-Feb-09 23:54
Cedric Moonen10-Feb-09 23:54 

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.