模板typename实例化错误

时间:2015-03-26 05:53:04

标签: c++ templates

template <typename List>
class list_base {
    typedef typename List::node node;

};


template <typename T, typename Allocator = allocator<T>>
class list: private list_base<list<T, Allocator>> {
    typedef Allocator allocator_type;

    class node {

    };
};

当我实例化list<int> x时,它会给我一个错误:

../src/Console.cpp: In instantiation of ‘class list_base<list<int> >’:
../src/Console.cpp:27:7:   required from ‘class list<int>’
../src/Console.cpp:36:12:   required from here
../src/Console.cpp:21:30: error: no type named ‘node’ in ‘class list<int>’

明确定义了类型节点。这里发生了什么?

1 个答案:

答案 0 :(得分:2)

问题:

  

明确定义了类型节点。这里发生了什么?

实例化基类时,未完全定义

list