【发布时间】:2010-12-26 13:07:06
【问题描述】:
我有一个模板类 A
template <typename T, int M> class A;
typedef A<std::string, 20> one_type;
typedef A<std::string, 30> second_type;
template <typename T, int M>
class A {
public:
A(int m) {test= (m>M);}
bool test;
};
template<>
one_type::one_type() { cerr << "One type" << endl;}
我希望 A<:string> 类做其他类不做的事情。如何在不更改构造函数 A:A(int) 的情况下做到这一点?
【问题讨论】:
-
你想让这些课程做什么?
-
问题不清楚。顺便说一句,one_type 没有空构造函数,它有带 int 参数的构造函数。
标签: c++ templates constructor specialization