Chinaunix首页 | 论坛 | 博客
  • 博客访问: 271398
  • 博文数量: 55
  • 博客积分: 2030
  • 博客等级: 大尉
  • 技术积分: 737
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-13 18:06
文章分类

全部博文(55)

文章存档

2011年(2)

2010年(7)

2009年(17)

2008年(29)

我的朋友

分类: C/C++

2008-09-18 02:14:04

member function templates
 

template<typename T>
class SmartPtr {
public:
  template<typename U> // member template
  SmartPtr(const SmartPtr<U>& other); // for a "generalized
  ... // copy constructor"
};

generalized copy constructors.

 

implicit type conversion functions are never considered during template argument deduction

As a declared function (not a function template), compilers can use implicit conversion functions (such as Rational's non-explicit constructor) when calling it

Inside a class template, the name of the template can be used as shorthand for the template and its parameters, so inside Rational, we can just write Rational instead of Rational.

The only way to declare a non-member function inside a class is to make it a friend.

阅读(764) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~