我的代码是:
#include <iostream>
using namespace std;
template <typename T, int X>
class Test
{
private:
T container[X];
public:
void printSize();
};
template <typename T, int X>
void Test<T,X>::printSize()
{
cout <<"Container Size = "<<X <<endl;
}
int main()
{
cout << "Hello World!" << endl;
Test<int, 20> t;
Test<int, 30> t1;
t.printSize();
t1.printSize();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
题:
<int, 20> 用于<int, 30>.如果我的理解错了,请纠正吗?| 归档时间: |
|
| 查看次数: |
121 次 |
| 最近记录: |