First page Back Continue Last page Graphics
fig13_07.cpp
(3 of 3)
50 // use auto_ptr to manipulate Integer object
51 int main()
52 {
53 cout << "Creating an auto_ptr object that points to an "
54 << "Integer\n";
55
56 // "aim" auto_ptr at Integer object
57 auto_ptr< Integer > ptrToInteger( new Integer( 7 ) );
58
59 cout << "\nUsing the auto_ptr to manipulate the Integer\n";
60
61 // use auto_ptr to set Integer value
62 ptrToInteger->setInteger( 99 );
63
64 // use auto_ptr to get Integer value
65 cout << "Integer after setInteger: "
66 << ( *ptrToInteger ).getInteger()
67 << "\n\nTerminating program" << endl;
68
69 return 0;
70
71 } // end main