C++ C++;类和函数模板声明?
现在我正在尝试运行我的模板类和函数,但我不确定如何定义模板void函数。下面是我代码的一小部分。代码不运行,在使用arrayList类的任何时候,都会显示arrayList的C++ C++;类和函数模板声明?,c++,function,templates,C++,Function,Templates,现在我正在尝试运行我的模板类和函数,但我不确定如何定义模板void函数。下面是我代码的一小部分。代码不运行,在使用arrayList类的任何时候,都会显示arrayList的参数列表缺失 #include <iostream> using namespace std; template<typename Type> //Template class declaration class arrayList { public: void print() const
参数列表缺失
#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;
}
#包括
使用名称空间std;
模板//模板类声明
类数组列表
{
公众:
无效打印()常量;
受保护的:
int*list;//保存列表元素的数组
int length;//用于存储列表的长度
int maxSize;//存储列表的最大大小
};
样板
void arrayList::print()常量
{
int i;
对于(i=0;i
模板
void arrayList::print()常量。。。
您文章的哪一部分代表了“最小的可编译示例”中的最小值?
template<typename Type>
void arrayList<Type>::print() const ...