【发布时间】:2018-01-20 20:40:34
【问题描述】:
我正在编写一个包含对象数组的类模板。 我收到一条错误消息,提示“构造函数语法缺少形式参数”。 该错误与代码行DT List[100]相关;
template <class DT>
class List
{
private:
DT List[100];
int numberInList;
int listSize;
int nextIndex;
public:
List();
void insert(DT&);
DT getNext();
bool getMember(DT&);
int getNumber();
};
#endif
template<class DT>
List<DT>::List()
{
numberInList = 0;
listSize = 0;
nextIndex = 0;
}
【问题讨论】:
-
请read about how to ask good questions,并尝试创建一个Minimal, Complete, and Verifiable Example 向我们展示。并且请将编译器的 full 和 complete 输出复制粘贴(作为文本)到问题正文中。
-
你为什么要创建一个与类同名的变量?这不能很好地工作
标签: c++ class-template