当我这样做时,我的编译器抱怨.虽然没有可见的错误消息,但会出现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;
};
Run Code Online (Sandbox Code Playgroud)
编译器不喜欢我的vector<Node> storage声明.当我这样做时vector<int> storage,它编译没有抱怨.在另一个类中声明一个类的对象是错误的吗?我觉得这没关系.
看起来你需要在定义Node之前加上定义Maker.
您Node在Maker(在行中vector<Node> storage)的定义中使用类型名称,但因为您还没有定义Node,编译器不知道它是什么.