... object
14      unique_ptr<Integer> ptrToInteger{make_unique<Integer>(7)};
15
16      cout << "\nUsing the unique_ptr to set the Integer\n";
17      ptrToInteger->setInteger(99); // use unique_ptr to set Integer value
18
19      // use unique_ptr to get Integer value
20      cout << "Integer after setInteger: " << (*ptrToInteger).getInteger()
21          << "\n\nTerminating program" <<  endl;
22   }

Creating a unique_ptr object that points to an Integer
Constructor for Integer 7

Using the unique_ptr to set the Integer
Integer after setInteger: 99

Terminating program
Destructor for Integer 99

Line 17 uses the unique_ptr overloaded -> operator to invoke function setInteger on the Integer object that ptrToInteger manages. Line 20 uses the unique_ptr overloaded * operator to dereference ...

Get C++ How to Program, 10/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.