嘿,我想弄清楚是否可以用表达式参数“重载”模板类定义。有点像下面的代码片段。
template<class T>
class Test
{
public:
T testvar;
Test()
{
testvar = 5;
cout << "Testvar: " << testvar << endl;
}
};
template<class T>
class Test<T, int num>
{
public:
T testvar;
Test()
{
testvar = 10;
cout << "Testvar: " << testvar << endl;
cout << "Param: " << num << endl;
}
};
谢谢。
编辑:为了记录,如果这不是很明显,我正在尝试用 C++ 来做到这一点...... :)