Lecture overview -- Keyboard shortcut: 'u'  Previous page: Resource acquisition is initialization - RAII -- Keyboard shortcut: 'p'  Next page: Smart pointers in C++11: unique_ptr and shared_ptr -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Alphabetic index  Help page about these notes  Course home    Abstraction Mechanisms, Part 1 - slide 16 : 41

Auto Pointers

An auto pointer, auto_ptr, is an encapsulation of a pointer that uses the RAII resource management idea

point.h
The usual class Point - nothing of particular interest.
auto-ptr1.cc
An illustration of auto_ptr<Point>.
program-output
The program output.

An auto pointer 'owns the pointer' - no other auto pointer should exist to the object

Due to the special meaning of copying, auto pointers cannot be used as the element type in standard containers