为什么我不能在班上做这个对象声明?

San*_*raj 1 c++ class object

当我这样做时,我的编译器抱怨.虽然没有可见的错误消息,但会出现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,它编译没有抱怨.在另一个类中声明一个类的对象是错误的吗?我觉得这没关系.

Dan*_*Dan 7

看起来你需要在定义Node之前加上定义Maker.

NodeMaker(在行中vector<Node> storage)的定义中使用类型名称,但因为您还没有定义Node,编译器不知道它是什么.