Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
Miscellaneous
complex
exception
functional
iterator
limits
locale
memory
new
numeric
stdexcept
typeinfo
utility
valarray
memory
classes:
allocator
auto_ptr
auto_ptr_ref
raw_storage_iterator
functions:
get_temporary_buffer
return_temporary_buffer
uninitialized_copy
uninitialized_fill
uninitialized_fill_n
auto_ptr
auto_ptr::auto_ptr
auto_ptr::~auto_ptr
member functions:
auto_ptr::get
auto_ptr::operator*
auto_ptr::operator->
auto_ptr::operator=
auto_ptr::operator
auto_ptr::release
auto_ptr::reset


auto_ptr::get

public member function
X* get() const throw();

Get pointer

Returns a pointer to the object pointed by the auto_ptr object, if any, or zero if it does not point to any object.

Parameters

none

Return value

A pointer to the element pointed by the auto_ptr object.
If the auto_ptr object is not pointing to any object, a zero-value is returned.
X is auto_ptr's template parameter (i.e., the type pointed).


Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// auto_ptr::get example
#include <iostream>
#include <memory>
using namespace std;
int main () {
  auto_ptr<int> p (new int);
  *p.get() = 100;
  cout << "p points to " << *p.get() << endl;
  return 0;
}


Possible output:

p points to 100

See also