明确的专业化 [英] explicit specialization od c'tor
问题描述
//变量创建对象
模板< class T> CL级
{
public:
CL(const T& t){}
template<> ; CL< double>(const T& t){}
};
如何为T = double制作构造函数,...,所以我可以在两种类型之间区分
。
谢谢,
-
-Gernot
int main(int argc,char ** argv){printf
("%silto%c%cf%cgl%ssic%ccom%c" ;,ma,58,''g'',64," ba",46,10);}
________________________________________
寻找一场精彩的比赛?亲自动手吧!
GLBasic - 你可以这样做
www.GLBasic .com
" Gernot Frisch" < Me@Privacy.net> skrev i en meddelelse
news:35 ************* @ individual.net ...//变量创建对象
template< class T> CL级
{
公开:
CL(const T& t){}
模板<> CL< double>(const T& t){}
};
如何为T = double制作构造函数,...,所以我可以区分
类型。
只需要构造函数没有模仿:
模板< class T> CL级
{
public:
CL(const T& t){}
CL(double t ){}
};
/ Peter
谢谢,
-
-Gernot
int main(int argc,char ** argv){printf("%silto%c%cf%cgl%ssic%ccom%c",
" ma",58 ,''g'',64," ba",46,10);}
________________________________________
寻找好游戏?亲自动手吧!
GLBasic - 你可以做
www.GLBasic.com
Gernot Frisch写道:
//变量创建对象
模板< class T> CL级
{
公开:
CL(const T& t){}
模板<> CL< double>(const T& t){}
};
如何为T = double制作构造函数,...,所以我可以区分
类型。
我想不出另一种方式...
模板<>
类CL< double>
{
public:
CL(const double& t){}
};
-
Ioannis Vranos
http://www23.brinkster.com/noicys
Peter Koch Larsen写道:
< blockquote class =post_quotes>简单地让构造函数无法模仿:
template< class T> CL级
{
公开:
CL(const T& t){}
CL(double t){}
};
>
这不起作用。
-
Ioannis Vranos
http://www23.brinkster.com/noicys
>
// variable creation object
template <class T> class CL
{
public:
CL (const T& t) {}
template <> CL<double>(const T& t) {}
};
How do I make a constructor for T = double, ..., so I can distinguish
between the types.
Thank you,
--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, ''g'', 64, "ba", 46, 10);}
________________________________________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com
"Gernot Frisch" <Me@Privacy.net> skrev i en meddelelse
news:35*************@individual.net...// variable creation object
template <class T> class CL
{
public:
CL (const T& t) {}
template <> CL<double>(const T& t) {}
};
How do I make a constructor for T = double, ..., so I can distinguish
between the types.
Simply have the constructor untemplated:
template <class T> class CL
{
public:
CL (const T& t) {}
CL(double t) {}
};
/Peter
Thank you,
--
-Gernot
int main(int argc, char** argv) {printf ("%silto%c%cf%cgl%ssic%ccom%c",
"ma", 58, ''g'', 64, "ba", 46, 10);}
________________________________________
Looking for a good game? Do it yourself!
GLBasic - you can do
www.GLBasic.com
Gernot Frisch wrote:
// variable creation object
template <class T> class CL
{
public:
CL (const T& t) {}
template <> CL<double>(const T& t) {}
};
How do I make a constructor for T = double, ..., so I can distinguish
between the types.
I cannot think of another way...
template <>
class CL<double>
{
public:
CL (const double& t) {}
};
--
Ioannis Vranos
http://www23.brinkster.com/noicys
Peter Koch Larsen wrote:
Simply have the constructor untemplated:
template <class T> class CL
{
public:
CL (const T& t) {}
CL(double t) {}
};
This does not work.
--
Ioannis Vranos
http://www23.brinkster.com/noicys
这篇关于明确的专业化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!