A function can be called directly in the C language using the function address:
void print () { printf ("function print");} typdef void (*fun) (); Fun F = print;f ();
class non-static member functions in C + + must be called through an instance, and class member functions in C + + are called:
Class Test{public:void print () { printf ("function print");}};
we can also invoke the following by defining a function pointer:
typedef void (test::* Fun) (), Fun f = &test::p rint;test t; (t.*f) ();
if we want to take the function address, direct strong transfer Error
unsigned int a = reinterpret_cast<unsigned int> (f);//Compilation error
http://bbs.pediy.com/showthread.php?t=47835
Here's the answer.
char buf [+] = {0};sprintf (buf, "%u", f); int a = Atoi (BUF);
In fact, we know that the class member function is just the first parameter of the function is the this pointer, but the this pointer is not pushed through the normal function parameters, but put into the ecx.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
A brief analysis of C + + Get class member function address method