Reputation: 19578
I want to create a list of stacks in C++ but the compiler gives me some error messages:
#include <list>
#include <stack>
class cName
{
[...]
list<stack> list_stack;
[...]
}
Errors:
error C2143: syntax error : missing ';' before '<'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2238: unexpected token(s) preceding ';'
Upvotes: 2
Views: 135
Reputation: 3127
If you want your stack to handle just one type, for example int, change stack
in your code to int
:
list<int> list_stack;
Otherwise you should create your own template type instead of using stack
:
template <class T>
class List
{
list<T> list_stack;
T top();
void push(T v);
};
Upvotes: 1
Reputation: 45410
std::stack is a template, you need to use it with template arguments. For sample:
class cName
{
typedef int ConcreteType;
std::list<stack<ConcreteType> > list_stack;
^^^^ use it with real type
};
Upvotes: 4
Reputation: 20129
Stacks are also templated, so it should be
list<stack <...> > list_stack;
Upvotes: 1