HOWTO: Access member function pointer?

zhaozj2021-02-17  68

HOWTO: Access member function pointer?

#include

#include

Typedef Double Type;

Class A

{

PUBLIC:

Bool Fun (Type & n) // Parameter is the reference type can be unified (Very Good!)

{

Cout << "A :: fun ()" << n << endl;

Return True;

}

void * getp ()

{

Bool (a :: * pfun) (Type &);

PFUN = FUN;

Return * (void **) & pfun; // Note: return (void *) & pfun; is wrong!

}

}

Class B

{

PUBLIC:

A a a;

Void show (void * pvoid)

{

Void * p = a.getp ();

A * PA = & A;

_asm

{

MOV EAX, PVOID // If the parameter is not a pointer type, use Lea Eax, Param

Push EAX

MOV ECX, PA // To place the address of the object in ECX

Call P

}

}

}

void main ()

{

B b;

INT i = 100;

Double D = 100.236;

CSTRING STR ("I am ZHT");

B.SHOW (& D);

}

转载请注明原文地址:https://www.9cbs.com/read-31209.html

New Post(0)