简体   繁体   English

模板类和继承问题-“列表”未命名非静态数据成员或基类

[英]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.

相关问题 当初始值设定项是基类名称时出现错误“初始值设定项未命名非静态数据成员或基类” - Error 'initializer does not name a non-static data member or base class' when the initializer is the base class name 成员初始化程序“ SuperClass”未命名非静态数据成员或基类 - member initializer 'SuperClass' does not name a non-static data member or base class “没有与第一个非静态数据成员相同类型的基类” - “no base classes of the same type as the first non-static data member” 枚举不是类的非静态数据成员或基类 - enum is not a non-static data member or base class of class 成员初始值设定项不命名非静态数据成员 - Member initializer does not name a non-static data member 类到模板错误:无效使用非静态数据成员 - Class to template error: invalid use of non-static data member C ++ 11非静态数据成员统一初始化失败,指针指向同一基类的其他类 - C++11 non-static data member uniform initialization fails for pointers to other classes of same base class 该类中已删除的析构函数显示为虚拟/直接基类或非静态数据成员的类型 - Deleted destructor in the class appeared as a virtual/direct base class or as a type of non-static data member C ++派生类是否可以从Base类继承静态数据成员和静态成员函数? - C++ Does derived class could inheritance Static data member and Static Member function from Base class? boost :: bind用于模板类中的非静态成员函数 - boost::bind for a non-static member function in a template class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM