kanyuchun
asked on
about pointer to point a function.
In the class A has a pointer P1 which has been defined point to function. The class A have function F1,F2,F3 too.In the F3 I write P1=F1; But it is wrong! when I want to build it.
class A
{
public:
int F1(int i);
int F2(int i);
int F3(int i);
int (*P1)(int i);
}
int F3(int i)
{
P1=F1; //here will be wrong!
*P1(7);
}
pleas give me answer with exampl.
thank you.
:-)
class A
{
public:
int F1(int i);
int F2(int i);
int F3(int i);
int (*P1)(int i);
}
int F3(int i)
{
P1=F1; //here will be wrong!
*P1(7);
}
pleas give me answer with exampl.
thank you.
:-)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Depends what exactly you are trying to do. You can encapsulate the behaviour of a member function pointer in a class, or you can call static member functions in the normal way.
The basic problem is thought that to call a method you need both an object instance and a method pointer. Let me know more about what you want, and maybe I can help.
The basic problem is thought that to call a method you need both an object instance and a method pointer. Let me know more about what you want, and maybe I can help.
ASKER
hi,jasonclarke
thank you very much!
I have solved my problem already!
~(@_@)~
thank you very much!
I have solved my problem already!
~(@_@)~
ASKER
Are there any other way to do it ?