【发布时间】:2015-06-04 14:09:49
【问题描述】:
最近我卡在模板中,我在模板中传递了一个虚拟参数,但这不起作用,并给出编译错误,这是我的代码..
#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;
}
在我看来它应该可以正常工作,但它给出了重新声明错误,我不知道为什么.....请帮助谢谢
【问题讨论】:
标签: c++