Click here to Skip to main content
15,914,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHelp , why WSAGetLastError( ) return 2? Pin
danscort yu9-Jun-07 16:42
danscort yu9-Jun-07 16:42 
AnswerRe: Help , why WSAGetLastError( ) return 2? Pin
danscort yu9-Jun-07 17:12
danscort yu9-Jun-07 17:12 
AnswerRe: Help , why WSAGetLastError( ) return 2? Pin
Mark Salsbery9-Jun-07 18:17
Mark Salsbery9-Jun-07 18:17 
GeneralRe: Help , why WSAGetLastError( ) return 2? Pin
danscort yu9-Jun-07 21:13
danscort yu9-Jun-07 21:13 
GeneralRe: Help , why WSAGetLastError( ) return 2? Pin
Mark Salsbery10-Jun-07 5:44
Mark Salsbery10-Jun-07 5:44 
GeneralRe: Help , why WSAGetLastError( ) return 2? Pin
danscort yu11-Jun-07 1:02
danscort yu11-Jun-07 1:02 
QuestionRe: Help , why WSAGetLastError( ) return 2? Pin
Mark Salsbery11-Jun-07 6:25
Mark Salsbery11-Jun-07 6:25 
QuestionPassing a class function pointer as an argument Pin
Cyrilix9-Jun-07 14:30
Cyrilix9-Jun-07 14:30 
The function pointer tutorials have a good example of passing a global function pointer as an argument and it's laid out in the following manner:

//------------------------------------------------------------------------------------
// 2.6 How to Pass a Function Pointer

// <pt2Func> is a pointer to a function which returns an int and takes a float and two char
int DoIt(float x, char y, char z)
{
   return 0;
}

void PassPtr(int (*pt2Func)(float, char, char))
{
   int result = (*pt2Func)(12, 'a', 'b');     // call using function pointer
}

// execute example code - 'DoIt' is a suitable function like defined above in 2.1-4
void Pass_A_Function_Pointer()
{
   PassPtr(&DoIt);
}


My scenario is a bit different though. It's something more like:

//------------------------------------------------------------------------------------
// 2.6 How to Pass a Function Pointer

// <pt2Func> is a pointer to a function which returns an int and takes a float and two char
int Class::DoIt(float x, char y, char z)
{
   return 0;
}

void PassPtr(int (*pt2Func)(float, char, char))
{
   int result = (*pt2Func)(12, 'a', 'b');     // call using function pointer
}


If I do the same as in the first instance and call PassPtr(&DoIt), it won't compile, giving me the following error when declaring the function pointer:

error C2276: '&' : illegal operation on bound member function expression

If I change the call to PassPtr(&Class::DoIt), it won't compile, giving me the following error when trying to pass the function pointer:

error C2664: <snip> cannot convert parameter 1 from 'int (__thiscall Class::* )(float, char, char)' to 'int (__cdecl *)(float, char, char)'

Some names have been changed, but this is pretty much what's going wrong. Does anyone know how to solve this issue? It would seem like I need to declare just a global function instead of actually passing a class member function.
AnswerRe: Passing a class function pointer as an argument Pin
Nemanja Trifunovic9-Jun-07 14:48
Nemanja Trifunovic9-Jun-07 14:48 
GeneralRe: Passing a class function pointer as an argument Pin
Cyrilix9-Jun-07 14:52
Cyrilix9-Jun-07 14:52 
AnswerRe: Passing a class function pointer as an argument Pin
Mark Salsbery9-Jun-07 15:01
Mark Salsbery9-Jun-07 15:01 
GeneralRe: Passing a class function pointer as an argument Pin
Cyrilix9-Jun-07 15:17
Cyrilix9-Jun-07 15:17 
GeneralRe: Passing a class function pointer as an argument Pin
Mark Salsbery9-Jun-07 15:28
Mark Salsbery9-Jun-07 15:28 
GeneralRe: Passing a class function pointer as an argument Pin
Cyrilix9-Jun-07 15:40
Cyrilix9-Jun-07 15:40 
GeneralRe: Passing a class function pointer as an argument Pin
Mark Salsbery9-Jun-07 15:59
Mark Salsbery9-Jun-07 15:59 
QuestionSet registry key permissions Pin
KellyR9-Jun-07 10:42
KellyR9-Jun-07 10:42 
QuestionRe: Set registry key permissions Pin
KellyR9-Jun-07 12:07
KellyR9-Jun-07 12:07 
AnswerRe: Set registry key permissions Pin
KellyR10-Jun-07 6:51
KellyR10-Jun-07 6:51 
QuestionHelp Pin
dellthinker9-Jun-07 10:32
dellthinker9-Jun-07 10:32 
AnswerRe: Help Pin
KellyR9-Jun-07 11:03
KellyR9-Jun-07 11:03 
AnswerRe: Help Pin
Christian Graus9-Jun-07 14:10
protectorChristian Graus9-Jun-07 14:10 
QuestionForce Closing of a Module Pin
Bram van Kampen9-Jun-07 9:37
Bram van Kampen9-Jun-07 9:37 
AnswerRe: Force Closing of a Module Pin
Perspx9-Jun-07 13:26
Perspx9-Jun-07 13:26 
AnswerRe: Force Closing of a Module Pin
Mark Salsbery9-Jun-07 14:21
Mark Salsbery9-Jun-07 14:21 
GeneralRe: Force Closing of a Module Pin
Bram van Kampen10-Jun-07 3:17
Bram van Kampen10-Jun-07 3:17 

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.