SmartPointer that Iterates through a Container
Understand the implementation of a user-defined "SmartPointer" class that iterates through a linked list container.
We'll cover the following...
We'll cover the following...
Problem
Write a program that maintains a linked list using a Container class. Also, implement a SmartPointer class that lets you access Container elements using the * operator and lets you iterate through the Container using the ++ operator.
Sample run
Here’s what you should see when you run the program.
10
20
0
-40
50
Coding solution
Here is a solution to the problem above.
Explanation
A container is a way to organize data in memory. Hence stacks, linked lists, arrays are all containers. An iterator is an object that moves through a container accessing various elements of the container.
We can iterate through an ordinary C++ array by using ...