c – 模板代码中的默认类型参数错误

前端之家收集整理的这篇文章主要介绍了c – 模板代码中的默认类型参数错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. 1)template <class T = int,class U = double> //compiles
  2.  
  3. 2)template <class T,class U =double> //compiles
  4.  
  5. 3)template <class T = int,class U> //fails@H_502_3@
  6. 为什么12编译而3不编译?

解决方法

出于同样的原因:
  1. void f(int = 0,int);@H_502_3@
  2. 失败.

  3. 无法使用第3版默认参数:

  4. template<class T = int,class U> class B { ... };
  5. B<,short> var; // ??? no such Syntax@H_502_3@

猜你在找的C&C++相关文章