我正在尝试编写一个容器适配器。我也想在派生类中使用基类的类型定义。所以我尝试了以下...
template <class CONTAINER> class SequenceComposite {
protected:
CONTAINER m_data;
public:
typedef typename CONTAINER::size_type size_type;
// ...
};
template <class DTYPE>
class VectorComposite : public virtual SequenceComposite< std::vector<DTYPE> > {
public:
size_type capacity() const { m_data.capacity(); }
// ...
};
我收到这个错误...
error: ‘size_type’ does not name a type
note: (perhaps ‘typename SequenceComposite<std::vector<T> >::size_type’ was intended) // yes, it was
如何告诉编译器我想使用基类中的 typedef?