我正在寻找一些代码让它工作
template <typename T, int a, int b>
class first
{ //not so important
};
main()
{
first<double,1,2> sth;
second<double> sth2;
}
Sth2 与 sth 是同一类型,但有默认参数(例如) 我知道我需要一些 typedef。我试过了
template <typename T>
struct help
{
typedef first<T,1,1> second;
};
但它只适用于额外的::(help
感谢您的任何想法:)
最佳答案
你应该能够定义
template <typename T, int a=1, int b=2> class first
然后
first<double> sth2;
但是如果你真的想要两个类
template <typename T> class second : public first<T,1,1>
应该能带你去某个地方。
关于C++:重命名模板类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20926164/