
obtain class member function address?
Since the member function you are seeking the address of is private, you
will not be able to get it without supplying some means within the class to
get its pointer. This would require a public member that would return the
pointer to you. I'm not sure of your particular application, but it would
seem that allowing one to retrieve the pointer to a private member somewhat
defeats the purpose of making it private.
Now, I would not encourage doing the following, but below is a console
app code snippet which shows how you can do what you are trying to
accomplish:
----------------------- cut here -----------------
#include <iostream>
#include <windows.h>
class CTest;
typedef DWORD (WINAPI CTest::*PPFUNC)(LPVOID);
class CTest {
public:
PPFUNC GetMyFuncPtr();
private:
DWORD WINAPI MyFunction(LPVOID);
Quote:
};
PPFUNC
CTest::GetMyFuncPtr()
{
return(MyFunction);
Quote:
}
DWORD
CTest::MyFunction(
LPVOID)
{
return(42);
Quote:
}
void main()
{
CTest test;
PPFUNC pFunc=test.GetMyFuncPtr();
std::cout << (test.*pFunc)(&test) << std::endl;
Quote:
}
----------------------- cut here -----------------
Joe
-------------------------------
Quote:
>Hi,
>Does anybody know how can I get class member function address with VC++
5.0.
>Code sample:
> class MyClass
> {
> ...
> private:
> ...
> DWORD WINAPI MyFunction (LPVOID);
> ...
> }
>I need to get address of MyFunction. Is it posible in VC?