how to use ::*
-
I have seen some code recently in the Unreal Tournament public source code that uses types like "void(UObject::*Func)( FFrame& TheStack, RESULT_DECL );" and I am trying to figure out how to use this in my own code. I have written something like below but I always get the error "C2064: term does not evaluate to a function"
class A { public: void TestFunc() { printf("Hello\n"); } }; void Test(void(A::*Prm1)(void)) { Prm1(); } int main(int argc, char **argv) { Test(A::TestFunc); return 0; }
It won't even let me cast it to a DWORD or any other types but you must be able to do something with it or it would not exist. So is there anyone here who can tell me how to use this (I dont even know what to call it), I have tried searching but all the search engines that I have tried have problems with "::*". -
I have seen some code recently in the Unreal Tournament public source code that uses types like "void(UObject::*Func)( FFrame& TheStack, RESULT_DECL );" and I am trying to figure out how to use this in my own code. I have written something like below but I always get the error "C2064: term does not evaluate to a function"
class A { public: void TestFunc() { printf("Hello\n"); } }; void Test(void(A::*Prm1)(void)) { Prm1(); } int main(int argc, char **argv) { Test(A::TestFunc); return 0; }
It won't even let me cast it to a DWORD or any other types but you must be able to do something with it or it would not exist. So is there anyone here who can tell me how to use this (I dont even know what to call it), I have tried searching but all the search engines that I have tried have problems with "::*".Try this:
class A
{
public:
void f() { printf("Hello\n"); }
};void Test(void (A::*fun)(void))
{
A a;
(a.*fun)();
};void main()
{
Test(&A::f);
}If you call a non-static function via pointer-to-member, you have to specify a instance of class, that is passed to the member function. Robert-Antonio "Love, truth and electric traction must gain victory over hate, lie and diesel traction."
-
Try this:
class A
{
public:
void f() { printf("Hello\n"); }
};void Test(void (A::*fun)(void))
{
A a;
(a.*fun)();
};void main()
{
Test(&A::f);
}If you call a non-static function via pointer-to-member, you have to specify a instance of class, that is passed to the member function. Robert-Antonio "Love, truth and electric traction must gain victory over hate, lie and diesel traction."