//mediafactory.h
class MediaFactory{
public:
typedef Media* (*funPointer)();
funPointer somePointer;
}
//mediafactory.cpp
Media* MediaFactory::returnMedia(){
}
当我尝试做
somePointer = returnMedia;
我收到此错误:
1 IntelliSense: a value of type "Media *(MediaFactory::*)()" cannot be assigned to an entity of type "MediaFactory::funPointer" c:\Users\...\mediafactory.cpp 37
但是,如果我将函数更改为下面的代码,它将编译并工作
Media* returnMedia(){ //without scope
}