C++ stl,函数没有返回类型

Yoh*_*xFF 2 c++ stl

template<typename _Tp1>
operator auto_ptr_ref<_Tp1>() throw()
{ return auto_ptr_ref<_Tp1>(this->release()); }

template<typename _Tp1>
operator auto_ptr<_Tp1>() throw()
{ return auto_ptr<_Tp1>(this->release()); }
Run Code Online (Sandbox Code Playgroud)

我在stl类auto_ptr中找到了这两个方法的定义.

有人可以解释一下,其他函数如何构造函数没有返回类型?

小智 6

因为他们是隐式转换操作符,返回auto_ptr_ref<_Tp1>auto_ptr<_Tp1>分别.这些本身用作返回类型声明.