当我这样做的时候,我的编译器会抱怨。出现了3个错误,但看不到错误消息:
#include <stdlib.h>
#include <vector>
#include <string>
#include "ParseException.h"
#include "CycleFoundException.h"
#include "UnknownTargetException.h"
using namespace std;
class Maker
{
private:
vector<Node> storage;
public:
Maker(string file) throw (ParseException, CycleFoundException, UnknownTargetException);
vector<string> makeTarget(string targetName);
};
struct Node
{
string target;
vector<string> dependencies;
string command;
int discoverytime;
int finishtime;
int visited;
Node* next;
};编译器不喜欢我的vector<Node> storage声明。当我改为使用vector<int> storage时,它编译起来没有任何问题。在另一个类中声明一个类的对象是错误的吗?我还以为这没问题呢。
发布于 2012-11-13 05:08:07
看起来你需要把Node的定义放在Maker的定义之前。
您在Maker的定义中使用了类型名称Node (在vector<Node> storage行中),但是因为您还没有定义Node,所以编译器还不知道它是什么。
https://stackoverflow.com/questions/13351556
复制相似问题