Reputation: 79
I'm trying to create a vector of a class I just set up and I keep getting errors. Can anyone give me some advice? Here's my relevant code:
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;
the error I'm getting is:
"template argument for 'template<class _Alloc> class std::allocator' uses local type 'main(int,
char**)::process*'"
Upvotes: 1
Views: 855
Reputation: 14039
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.
Upvotes: 5
Reputation: 283684
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.
Upvotes: 2