共用方式為


auto_ptr::operator auto_ptr<Other>

從一種型別轉換至其他類型的 auto_ptrauto_ptr

template<class Other> 
   operator auto_ptr<Other>( ) throw( );

傳回值

這個型別轉型運算子傳回 auto_ptr <[其他]>(*this)。

範例

// auto_ptr_op_auto_ptr.cpp
// compile with: /EHsc
#include <memory>
#include <iostream>
#include <vector>

using namespace std;
int main()
{
   auto_ptr<int> pi ( new int( 5 ) );
   auto_ptr<const int> pc = ( auto_ptr<const int> )pi;
}

需求

標頭: <memory>

命名空間: std

請參閱

參考

auto_ptr 類別