我正在尝试为基类编译实现文件,该基类具有在从不同基类派生的类型上自行运行的函数。大纲如下:
element.h展开
ifndef ELEMENT_H
#define ELEMENT_H
#include "transitionList.h"
class Element{
//other code
public:
Element();
virtual ~Element();
virtual TransitionList* get_successor();
virtual void set_successor(TransitionList* e);
//other code
};
#endif
element.cpp
#include "transitionList.h"
#include "element.h"
Element::Element(){}
Element::~Element(){}
// other code
TransitionList* Element::get_successor(){}
Element::set_successor(TransitionList* e){}
transitionList.h
#ifndef TRANSITION_LIST_H
#define TRANSITION_LIST_H
#include "list.h"
#include "transition.h"
class Transition;
class TransitionList: public List {
public:
TransitionList();
~TransitionList();
// other code
};
#endif
transitionList.cpp
#include "transitionList.h"
TransitionList::TransitionList(){}
TransitionList::~TransitionList(){}
// other code
transition.h
#ifndef TRANSITION_H
#define TRANSITION_H
#include "element.h"
#include "transitionList.h"
class TransitionList;
class Transition: public Element {
public:
Transition();
~Transition(){}
// other code
#endif
transition.cpp
#include "transition.h"
#include "element.h"
#include "transitionList.h"
Transition::Transition(){}
// other code
所以,当我尝试编译element.cpp时,我得到了
error: unknown type name 'TransitionList'
我不明白,因为它包含在element.h中。我想问题不是很有用,但是,我真的不知道可能需要什么。