#include<stdio.h>
typedef int (*printfun)(char
*str);
class A
{
public:
void ap(printfun pf)
{
pf("aaaaa");
printf("calss A\n");
}
};
class B
{
public:
int print(char
*str)
{
printf("class B : %s\n",str);
}
void bp()
{
A a;
a.ap(print);
}
};
void main()
{
B b;
b.bp();
}
vc6下编译错误:
C:\Documents and Settings\Administrator\test.cpp(27) : error C2664: 'ap' : cannot convert parameter 1 from 'int (char *)' to 'int (__cdecl *)(char *)'
None of the functions with this name in scope match the target type |