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>’
类型节点已明确定义。这里会发生什么?
最佳答案
题:
当实例化基类时,list
尚未完全定义。
关于c++ - 模板类型名实例化错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29271917/