Click here to Skip to main content
15,915,163 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Visual C++ . NET [ 2003] & Express 2005? Pin
thierrypp16-Mar-06 8:52
thierrypp16-Mar-06 8:52 
Questiontype casting function pointers Pin
Martijn van Kleef16-Mar-06 4:01
Martijn van Kleef16-Mar-06 4:01 
AnswerRe: type casting function pointers Pin
toxcct16-Mar-06 4:07
toxcct16-Mar-06 4:07 
GeneralRe: type casting function pointers Pin
Martijn van Kleef16-Mar-06 5:02
Martijn van Kleef16-Mar-06 5:02 
GeneralRe: type casting function pointers Pin
Michael Dunn16-Mar-06 5:19
sitebuilderMichael Dunn16-Mar-06 5:19 
AnswerRe: type casting function pointers Pin
mzdude16-Mar-06 5:04
mzdude16-Mar-06 5:04 
GeneralRe: type casting function pointers Pin
toxcct16-Mar-06 5:13
toxcct16-Mar-06 5:13 
AnswerRe: type casting function pointers Pin
Dan McCormick16-Mar-06 5:21
Dan McCormick16-Mar-06 5:21 
C++ refuses to 'throw away' the class association of the non-static class method, which is what is happening in the example you give with the class method. The compiler basically says, "If I lose the class association for this method, I won't be able to tie this method back to an instance of the class."

It's not an issue with the a global (i.e. non-class ) function because there is no class association. It's also not a problem with a static class method. Static class methods aren't much more than global functions that are 'hidden' inside a class namespace. They don't have an instance of the class associated with them when they are invoked.

If you really, really, really need to get the value as a DWORD, you can use a union to get there.
<br />
class CSomeClass<br />
{<br />
public:<br />
    void SomeMethod();<br />
};<br />
<br />
union<br />
{<br />
    DWORD dwValue;<br />
    void (CSomeClass::*pMethod)();<br />
} Address;<br />
<br />
// Assume pSomeClass points to an instance of CSomeClass;<br />
<br />
Address.pMethod = pSomeClass->SomeMethod;<br />
<br />
// You can now retrieve the 'address' of SomeMethod using<br />
// Address.dwValue<br />
<br />

Note that this technique is not implementation independent! Run on a machine that uses pointers that are not 32-bits and you have a problem.

Regards,
Dan

Remember kids, we're trained professionals.
Don't try this at home!

GeneralRe: type casting function pointers Pin
Martijn van Kleef16-Mar-06 21:59
Martijn van Kleef16-Mar-06 21:59 
GeneralRe: type casting function pointers Pin
Dan McCormick17-Mar-06 1:34
Dan McCormick17-Mar-06 1:34 
Questionhow to create a virtual serial port, and to monitor it Pin
szilics16-Mar-06 2:35
szilics16-Mar-06 2:35 
AnswerRe: how to create a virtual serial port, and to monitor it Pin
Chris Gao16-Mar-06 9:21
Chris Gao16-Mar-06 9:21 
QuestionPrinting without a printer Pin
Waldermort16-Mar-06 2:33
Waldermort16-Mar-06 2:33 
AnswerRe: Printing without a printer Pin
Jack Puppy16-Mar-06 2:49
Jack Puppy16-Mar-06 2:49 
GeneralRe: Printing without a printer Pin
Waldermort16-Mar-06 3:12
Waldermort16-Mar-06 3:12 
AnswerRe: Printing without a printer Pin
Ryan Binns16-Mar-06 17:24
Ryan Binns16-Mar-06 17:24 
QuestionCreateProcess Method Pin
Subramaniam s.V.16-Mar-06 2:04
Subramaniam s.V.16-Mar-06 2:04 
AnswerRe: CreateProcess Method Pin
Hamid_RT16-Mar-06 2:11
Hamid_RT16-Mar-06 2:11 
GeneralRe: CreateProcess Method Pin
SilentSilent16-Mar-06 3:16
SilentSilent16-Mar-06 3:16 
AnswerRe: CreateProcess Method Pin
Michael Dunn16-Mar-06 5:15
sitebuilderMichael Dunn16-Mar-06 5:15 
AnswerRe: CreateProcess Method Pin
Chris Gao16-Mar-06 9:26
Chris Gao16-Mar-06 9:26 
AnswerRe: CreateProcess Method Pin
Stephen Hewitt16-Mar-06 12:04
Stephen Hewitt16-Mar-06 12:04 
GeneralRe: CreateProcess Method Pin
Chris Gao16-Mar-06 15:34
Chris Gao16-Mar-06 15:34 
GeneralRe: CreateProcess Method Pin
Subramaniam s.V.16-Mar-06 17:35
Subramaniam s.V.16-Mar-06 17:35 
GeneralRe: CreateProcess Method Pin
Subramaniam s.V.16-Mar-06 17:48
Subramaniam s.V.16-Mar-06 17:48 

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.