Consuming a List ADT

Now, let's consume our new List data type. We will initialize a new List and give some items to it. We will then insert several items again and find out if it works. Then, we will remove an item that we previously searched for, and then search for the item again to ensure it has now gone. Here is the code that we can find in the main.cpp file of the List.cbp project:

// Project: List.cbp// File : main.cpp#include "List.h"using namespace std;int main(){    // Initialize a List    List list = List();    // Add several items to the List    list.Insert(0, 21);    list.Insert(1, 47);    list.Insert(2, 87);    list.Insert(3, 35);    list.Insert(4, 92);    // Print current List    cout << "List elements:" << endl;    for(int i = 0; i < list.Count(); ++i) { ...

Get C++ Data Structures and Algorithms 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.