2

C++ でスタックのリストを作成したいのですが、コンパイラからいくつかのエラー メッセージが表示されます。

 #include <list>
    #include <stack>

    class cName
    {
        [...]
        list<stack> list_stack;
        [...]
    }

エラー:

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 ';'
4

3 に答える 3

4

std::stackはテンプレートです。テンプレート引数とともに使用する必要があります。サンプル:

class cName
{
  typedef int ConcreteType;
  std::list<stack<ConcreteType> > list_stack;
                  ^^^^ use it with real type
};
于 2013-06-11T05:21:18.517 に答える
1

スタックもテンプレート化されているため、

list<stack <...> > list_stack;
于 2013-06-11T04:30:23.020 に答える