我写了一个名为的课Queue.当我尝试构建项目时,出现编译时错误.
该.h文件中:
template<class Queue_entry>
class MyQueue {
public:
MyQueue();
bool empty() const;
// add entry in the tail of the queue
Error_code append(Queue_entry &x);
// throw the entry of the front
Error_code serve();
// get the front entry of the queue
Error_code retrieve(Queue_entry &x) const;
protected:
Queue_entry entry[MAXQUEUE];
int count;
int front, rear;
};
Run Code Online (Sandbox Code Playgroud)
看来.cpp文件中有错误:
MyQueue.cpp:17:1:'MyQueue'不是类,命名空间或枚举
我不知道什么是错的,但是当我将模板更改为时
#define Queue_entry int
Run Code Online (Sandbox Code Playgroud)
它可以成功运行.
c++ ×1