Original Post
Hi all,
i need to retrieve the function pointer of non-static member functions but i fail
. so let me explain the problem with a few lines of codes.
typedef void (*MyFunc)()
class CMyClass
{
public:
void NonStaticMember();
static void StaticMember();
};
MyFunc UtulityFunction;
CMyClass A;
so next line is working. because the function is static and its address is given staticly by start of the application.
UtulityFunction = A.StaticMember; // no problem
but i need to do the same operation for non static member. it fails. failure is mentally. when an instance created each time the adresses of functions are changing dynamically for each object is it right?... son when i read the reference of c++ programming next sentence is said "For C++, such a pointer can be used to access static member functions. Pointers to class members must use pointer-to-member operators" accordingly that type of operation can be done with static_cast operator. i tried to write next line in the scope of these explanation
UtulityFunction = static_cast< MyFunc >(A.NonStaticMember)
but it fails either. how can i do it ?
[edited by - yaskil on February 19, 2003 2:22:06 AM]