小编use*_*689的帖子

错误:使用类模板需要模板参数列表

当我尝试运行我的程序时,此错误显示“错误 C2955:'FOURTEEN':使用类模板需要模板参数列表”

#include <iostream>
using namespace std;
template <class T, int n>
class FOURTEEN
{
private:
    T a[n];
public:
    void ReadData();
    void DisplayData();
};
void FOURTEEN::ReadData()
{
    for(int i=0;i<n;++i)
        cin>>a.[i];
}
void FOURTEEN::DisplayData()
{
    for(int i=0;i<n;++i)
        cin>>a.[i]<<'\t';
    cout<<endl;
}
int main()
{
    FOURTEEN <int, 5>P;
//Read data into array a of object P
    cout<<"Enter 5 numbers: ";
    P.ReadData();
//display data of array a of object P
    P.DisplayData();

    system("pause");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我是否必须在其他地方重新输入模板?

c++ templates class

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

c++ ×1

class ×1

templates ×1