也许这是某种标题问题……但是发生了什么:
编译器在以下行中报错:
编译器在以下行中报错:
Queue<Email> mailbox;
这是错误信息:
..\EmailSystem.h:25: error: ISO C++ forbids declaration of `Queue' with no type
..\EmailSystem.h:25: error: expected `;' before '<' token
Queue.h:
#ifndef QUEUE_H_
#define QUEUE_H_
#include <string>
#include "EmailSystem.h"
...
template <class B>
class Queue {
...
};
#endif /* QUEUE_H_ */
Queue.cpp:
#include "Queue.h"
...
template class Queue<Email>;
EmailSystem.h:
#ifndef EMAILSYSTEM_H_
#define EMAILSYSTEM_H_
#include <iostream>
#include <string>
#include <vector>
#include "Queue.h"
struct Email {
...
};
struct User {
std::string name;
Queue<Email> mailbox;
};
...
#endif /* EMAILSYSTEM_H_ */
std::deque
或std::queue
的特别原因吗? - Billy ONeal