【发布时间】:2014-07-09 00:25:03
【问题描述】:
现在我正在尝试让我的模板类和函数运行,但我不确定如何定义模板 void 函数。下面是我的一小部分代码。该代码不会运行,并且在任何时候使用类 arrayList 时都会显示argument list for arrayList is missing。
#include <iostream>
using namespace std;
template<typename Type> //Template class declaration
class arrayList
{
public:
void print() const;
protected:
int *list; //array to hold the list elements
int length; //to store the length of the list
int maxSize; //to store the maximum size of the list
};
template<typename Type>
void arrayList::print() const
{
int i;
for(i = 0; i < length; i++)
cout<<list[i]<<" ";
cout<<endl;
}
【问题讨论】:
-
您帖子的哪一部分代表了“最小可编译示例”中的最小?