1

設定したばかりのクラスのベクトルを作成しようとしていますが、エラーが発生し続けます。誰かアドバイスをくれませんか?関連するコードは次のとおりです。

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;

私が得ているエラーは次のとおりです。

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

4

2 に答える 2

5

I think you have defined class process inside main.

From the standard (older)

A local type, a type with no linkage, an unnamed type or a type compounded from any of these types shall not be used as a template-argument for a template type-parameter.

However, this has changed in c++11 and later.

So, define the class in global scope or use a compiler (or enable) which supports this feature. In g++, you can enable this with -std=c++0x or -std=c++11 depending on the version.

于 2013-04-28T04:14:42.213 に答える
2

Antimony has decoded the relevant details from your code that you didn't bother to mention.

The fix is to enable C++11 support in your compiler (typically -std=c++11 or -std=gnu++11). C++03 didn't permit using local classes as template arguments. C++11 does.

于 2013-04-28T04:14:55.567 に答える