다음을 통해 공유


auto_ptr::get

The member function returns the stored pointer myptr.

Type *get( ) const throw( );

반환 값

The stored pointer myptr.

예제

// auto_ptr_get.cpp
// compile with: /EHsc
#include <memory>
#include <iostream>
#include <vector>
using namespace std;

class Int 
{
public:
   Int(int i) 
   {
      x = i;
      cout << "Constructing " << ( void* )this  << " Value: " << x << endl; 
   };
   ~Int( ) 
   {
      cout << "Destructing " << ( void* )this << " Value: " << x << endl; 
   };

   int x;

};

int main( ) 
{
   auto_ptr<Int> pi ( new Int( 5 ) );
   pi.reset( new Int( 6 ) );
   Int* pi2 = pi.get ( );
   Int* pi3 = pi.release ( );
   if (pi2 == pi3)
      cout << "pi2 == pi3" << endl;
   delete pi3;
}
  

요구 사항

헤더 <memory>

네임스페이스: std

참고 항목

참조

auto_ptr 클래스