P
PSN
Hi all,
I have the following code, which ends up with an error, cannot convert
from "void (A::*)(unsigned int)" to "void (*)(unsigned int)". Could
anyone please explain why ?? It works well, when the function is
defined static. However I dont understand why does it have to be
static.
class A
{
public:
void print(unsigned int i) { cout << i << endl; }
};
int main()
{
A objA;
typedef void (*PRINT_FUNC) (unsigned int);
objA.print(437);
PRINT_FUNC printFunc;
printFunc = &A:rint;
printFunc(438);
return 0;
}
Thanks again,
P.
I have the following code, which ends up with an error, cannot convert
from "void (A::*)(unsigned int)" to "void (*)(unsigned int)". Could
anyone please explain why ?? It works well, when the function is
defined static. However I dont understand why does it have to be
static.
class A
{
public:
void print(unsigned int i) { cout << i << endl; }
};
int main()
{
A objA;
typedef void (*PRINT_FUNC) (unsigned int);
objA.print(437);
PRINT_FUNC printFunc;
printFunc = &A:rint;
printFunc(438);
return 0;
}
Thanks again,
P.