5
我在写队列类。但是当我使用mac osx来构建我的项目时遇到了一些问题。 当H文件喜欢这样的:C++使用模板时<class T>错误:..不是类
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;
};
它出现错误的CPP file.Error:
MyQueue.cpp:17:1: 'MyQueue' is not a class, namespace, or enumeration
我不知道它是如何得到wrong.But当我改变了模板
#define Queue_entry int
它可以成功运行。
'class'mate haha 感谢您的解决方案,您可以将此问题标记为已回答:) –