[英]Issues with template classes and inheritance - 'List' does not name a non-static data member or base class
I'm relatively new to c++ and having a very hard time figuring out the issue with what I am doing. 我对c ++还是比较陌生,很难弄清楚我在做什么。 I hope my description isn't too confusing, but I have two separate class hierarchies going on.
我希望我的描述不要太混乱,但是我要进行两个单独的类层次结构。 The base for both are class templates.
两者的基础都是类模板。
Class hierarchy one is as follows 类的层次结构如下
template <class T>
class Order {}
// StoreOrder inherits from Order
class StoreOrder: public Order<Item *> {}
Class hierarchy two is as follows. 类层次结构二如下。 The tricky part here is in OrderList
棘手的部分在OrderList中
template <class T>
class List{}
// OrderList inherits from List
class OrderList : public List<StoreOrder *>{}
OrderList::OrderList(): List(), DatabasePath(""){}
When I pass a StoreOrder as the List template type I get an error in the constructor function that says 当我将StoreOrder作为List模板类型传递时,在构造函数中收到一条错误消息:
'List' does not name a non-static data member or base class
All classes work fine in every other situation that I've used them, so I believe it has to do with the fact that StoreOrder and OrderList both derive from template classes. 在我使用过的所有其他情况下,所有类均能正常工作,因此我认为这与StoreOrder和OrderList都从模板类派生的事实有关。 Any help would be great.
任何帮助都会很棒。
Instead of: 代替:
OrderList::OrderList(): List(), DatabasePath(""){}
Use: 采用:
OrderList::OrderList(): List<StoreOrder *>(), DatabasePath(""){}
List
is not a type. List
不是类型。 List<StoreOrder*>
is a type. List<StoreOrder*>
是一种类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.