首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

模板构造函数的优先顺序是什么?该怎么处理

2012-11-03 
模板构造函数的优先顺序是什么?C/C++ codetemplate typename tclass a {public:a() {}a(a&) {}// 1templ

模板构造函数的优先顺序是什么?

C/C++ code
template <typename t>class a {public:    a() {}    a(a&) {}    // 1    template <typename t2>    a(a<t2>&) {}    // 2    template <typename t2>    a(t2&) {}    // 3    template <typename t2>    a(const a<t2>&) {}    // 4    template <typename t2>    a(const t2&) {}    // 5};    a<int> aa;    a<int> aa2(aa);    a<float> aa3(aa);


试了下
a<int> aa2(aa);的顺序依次是1、2、3
a<float> aa3(aa);的顺序依次是2、3、4、5

这有没有什么相关的规定?

[解决办法]
探讨

引用:
>都写的话,就有警告?
什么警告,我这怎么没有?具体代码上全了,这跟瞎子摸象似的,真费劲。


就是C4521警告,你的编译器没有?

谢谢了啊

热点排行