【发布时间】:2015-04-24 15:35:16
【问题描述】:
我正在尝试找出模板类。 我声明了一个模板类,它是模板。但现在我想将该字符传递给 PrintChar 类的构造函数。我不想使用模板。但是使用构造函数。我怎么能这样做?我想反转操作。我想以常规构造函数的方式而不是使用模板来完成它。我的结构如下。谢谢。
template<char C>
class PrintChar : public PrintIt {
//something...
};
main()
PrintChar<'*'> pstuff_star(min,max);
PrintChar<'~'> pstuff_tilde(min,max);
【问题讨论】:
-
你是想说你想写
PrintChar foo('*')并让它创建一个PrintChar<'*'>吗?
标签: c++ class templates constructor