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>’
明确定义了类型节点。这里发生了什么?
答案 0 :(得分:2)
问题:
实例化基类时,未完全定义明确定义了类型节点。这里发生了什么?
list
。