最近我被困在模板中,我在模板中传递了一个伪参数,但这不起作用,并且在这里给出了编译错误是我的代码..
#include <iostream>
using namespace std;
template<typename T>
class A{
private:
T b;
public:
A()
{
cout<<"1st is executing "<<endl;
}
};
template<typename T,int>
class A{
private:
T b;
public:
A(){
cout<<"2nd is executing "<<endl;
}
};
int main(){
A<string> a;
A<string,100> b;
}
在我看来,它应该可以正常工作,但它会给出重新声明错误,我不知道为什么..... plz帮助谢谢
答案 0 :(得分:0)
我不完全确定,但我认为它是template <typename T = int>