Overloaded -> Operator in a SmartPointer Class

Understand the implementation of a Container and a SmartPointer class.

We'll cover the following


Write a program that implements a Container class that maintains an array of Sample objects. Create a SmartPointer class that would act as a friend of the Container class. Overload the -> operator in the SmartPointer class such that in main( ) we can use the SmartPointer object like a pointer.

Sample run

Here’s what you should see when you run the program.

10      3.14
20      6.28
30      9.45
40      8.66

Coding solution

Here is a solution to the problem above.

Get hands-on with 1200+ tech skills courses.