0
我有一个基于节点的队列实现的代码,我应该扩展一个名为QueueInterface的抽象类。扩展模板抽象类时出错
template<typename T>
struct QueueInterface {
public:
virtual ~QueueInterface(){};
virtual bool isEmpty() const = 0;
virtual void enqueue(const T value) = 0;
virtual void dequeue() throw(PreconditionViolationException) = 0;
virtual T peekFront() const throw(PreconditionViolationException) = 0;
};
template<typename T>
struct Queue : QueueInterface {
Queue();
~Queue();
bool isEmpty() const;
void enqueue(const T value);
void dequeue() throw(PreconditionViolationException);
T peekFront() const throw(PreconditionViolationException);
private:
Node<T>* front;
Node<T>* back;
};
即使包含QueueInterface头文件,我也会收到expected class name before '{' token
错误。这是为什么发生?
最有可能是'Node.h'或'QueueInterface.h'中的拼写错误。 – NathanOliver
没有。我检查了。另外,为什么'Node.h'中的拼写错误会导致错误 – pyro97
这将是一个猜测的结果,而不知道其他文件的内容。你能尽可能地减少它们,同时还能得到这个错误吗? TIA(P.S:我的钱在失踪;在一个类声明结束时) – Borgleader