C++无法创建用户定义类的向量

Erk*_*Erk 1 c++ class vector

我正在尝试创建一个我刚设置的类的向量,并且我不断收到错误.谁能给我一些建议?这是我的相关代码:

class process{
    public:
        enum state {New,Ready,Running,Waiting,IO,Terminated};
        double CPUburst[MAXCPUBURSTS];
        double IOburst[MAXCPUBURSTS-1];
        int nCPUbursts; // The number of CPU bursts this process actually uses
        int priority, type; // Not always used
        int currentBurst; // Indicates which of the series of bursts is currently being handled
};

vector<process> processTable;
Run Code Online (Sandbox Code Playgroud)

我得到的错误是:

"template argument for 'template<class _Alloc> class std::allocator' uses local type 'main(int, char**)::process*'"

use*_*353 5

我认为你已经定义了class process内部main.

从标准(较旧)

本地类型,没有链接的类型,未命名的类型或从这些类型中的任何类型复合的类型不应该用作模板类型参数的模板参数.

但是,这在c ++ 11及更高版本中发生了变化.

因此,在全局范围内定义类或使用支持此功能的编译器(或启用).在g ++中,您可以使用-std=c++0x-std=c++11根据版本启用此功能.