이 클래스 고려 : 컴파일러는 구성원의 서브 클래스에 오류가 나오는C++ 가상 클래스, 서브 클래스 및 selfreference
class baseController {
/* Action handler array*/
std::unordered_map<unsigned int, baseController*> actionControllers;
protected:
/**
* Initialization. Can be optionally implemented.
*/
virtual void init() {
}
/**
* This must be implemented by subclasses in order to implement their action
* management
*/
virtual void handleAction(ACTION action, baseController *source) = 0;
/**
* Adds an action controller for an action. The actions specified in the
* action array won't be passed to handleAction. If a controller is already
* present for a certain action, it will be replaced.
*/
void attachActionController(unsigned int *actionArr, int len,
baseController *controller);
/**
*
* checks if any controller is attached to an action
*
*/
bool checkIfActionIsHandled(unsigned int action);
/**
*
* removes actions from the action-controller filter.
* returns false if the action was not in the filter.
* Controllers are not destoyed.
*/
bool removeActionFromHandler(unsigned int action);
public:
baseController();
void doAction(ACTION action, baseController *source);
};
}
이 서브 클래스
class testController : public baseController{
testController tc;
protected:
void init(){
cout << "init of test";
}
void handleAction(ACTION action, baseController *source){
cout << "nothing\n";
}
};
을
testController tc;
십이팔
.ayaying
error: field ‘tc’ has incomplete type
하지만 제거하고 클래스를 작동 시키면 작동하지 않습니다 ...이 오류를 피할 수있는 방법이 있습니까 ??? 그것은 나에게 이상하게 보입니다 ...
동일한 유형의 여러 컨트롤러를 잡아들이 의도지만, C에 새로운. 중요한 차이점 중 하나는'Class object; '와 같은 클래스 변수 선언의 의미입니다. C++에서이 변수는 Java에서와 같이 참조가 아닌'Class'의 실제 인스턴스입니다. –