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

C / C++ / MFC

 
GeneralRe: programming in c++ Pin
Albert Holguin21-Oct-11 4:46
professionalAlbert Holguin21-Oct-11 4:46 
GeneralRe: programming in c++ Pin
afsus23-Dec-11 23:44
afsus23-Dec-11 23:44 
GeneralRe: programming in c++ Pin
Manfred Rudolf Bihy20-Oct-11 15:49
professionalManfred Rudolf Bihy20-Oct-11 15:49 
GeneralRe: programming in c++ Pin
Erudite_Eric20-Oct-11 20:14
Erudite_Eric20-Oct-11 20:14 
AnswerRe: programming in c++ Pin
Bram van Kampen21-Oct-11 16:23
Bram van Kampen21-Oct-11 16:23 
Questionhow about setting MFC IN C++ Pin
afsus20-Oct-11 0:44
afsus20-Oct-11 0:44 
AnswerRe: how about setting MFC IN C++ Pin
André Kraak20-Oct-11 3:49
André Kraak20-Oct-11 3:49 
QuestionFunction pointer point to a object member function in C++? Pin
lvantin19-Oct-11 21:02
lvantin19-Oct-11 21:02 
Hi everyone,

Have a nice day, please help me following concern

I know that, Function pointer in C++ can point to an address of global function, or static public function of a class
For example:
typedef float (MyFunction)(float a, float b);

//Global function
float add(float a, float b)
{
return a+b;
}

Class Math
{
public static float add(float a, float b)
{
return a+b;
}
}
void main(char*args[])
{
MyFunction*fp;

//Point to global function
fp = add;
printf("%f",fp(1,2))
//Point to public static function
fp = Math::add;
printf("%f",fp(5,10));
}

But it can not point to address of a function of a specified object.

For example, function add in calss Math is not static
Class Math
{
public float add(float a, float b)
{
return a+b;
}
}

The following is impossible (compile error)
void main(char*args[])
{
MyFunction*fp;
//Point to public function of specified object instance
Math*m = new Math();
fp = m->add;
printf("%f",fp(5,10));
}

But it is the thing i really want. Because i want to know function add is executed in context of what object (in this case we can know it is object m).
Above example is something like the concept Delegate in .NET.

Is there any design pattern to make such a delegate for C++?

Thanks,
Tin,
AnswerRe: Function pointer point to a object member function in C++? Pin
Stefan_Lang19-Oct-11 23:21
Stefan_Lang19-Oct-11 23:21 
AnswerRe: Function pointer point to a object member function in C++? Pin
App_19-Oct-11 23:22
App_19-Oct-11 23:22 
Questionvisual studio run time problem Pin
trioum19-Oct-11 20:09
trioum19-Oct-11 20:09 
AnswerRe: visual studio run time problem Pin
Chuck O'Toole19-Oct-11 21:28
Chuck O'Toole19-Oct-11 21:28 
GeneralRe: visual studio run time problem Pin
trioum19-Oct-11 22:54
trioum19-Oct-11 22:54 
GeneralRe: visual studio run time problem Pin
«_Superman_»20-Oct-11 2:26
professional«_Superman_»20-Oct-11 2:26 
GeneralRe: visual studio run time problem Pin
trioum20-Oct-11 5:08
trioum20-Oct-11 5:08 
GeneralRe: visual studio run time problem Pin
Chuck O'Toole20-Oct-11 15:01
Chuck O'Toole20-Oct-11 15:01 
AnswerRe: visual studio run time problem Pin
Albert Holguin20-Oct-11 4:01
professionalAlbert Holguin20-Oct-11 4:01 
QuestionI need socket help UDP broadcast, sendbuf Pin
jkirkerx19-Oct-11 14:24
professionaljkirkerx19-Oct-11 14:24 
AnswerRe: I need socket help UDP broadcast, sendbuf Pin
Goto_Label_19-Oct-11 23:01
Goto_Label_19-Oct-11 23:01 
GeneralRe: I need socket help UDP broadcast, sendbuf Pin
jkirkerx20-Oct-11 6:25
professionaljkirkerx20-Oct-11 6:25 
AnswerRe: I need socket help UDP broadcast, sendbuf Pin
Albert Holguin20-Oct-11 4:14
professionalAlbert Holguin20-Oct-11 4:14 
GeneralRe: I need socket help UDP broadcast, sendbuf Pin
jkirkerx20-Oct-11 6:21
professionaljkirkerx20-Oct-11 6:21 
AnswerRe: I need socket help UDP broadcast, sendbuf Pin
Albert Holguin20-Oct-11 6:50
professionalAlbert Holguin20-Oct-11 6:50 
GeneralRe: I need socket help UDP broadcast, sendbuf Pin
jkirkerx20-Oct-11 8:54
professionaljkirkerx20-Oct-11 8:54 
GeneralRe: I need socket help UDP broadcast, sendbuf Pin
Albert Holguin20-Oct-11 11:31
professionalAlbert Holguin20-Oct-11 11:31 

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.