Skip to Content
C++ Data Structures and Algorithms
book

C++ Data Structures and Algorithms

by Wisnu Anggoro
April 2018
Intermediate to advanced content levelIntermediate to advanced
322 pages
6h 57m
English
Packt Publishing
Content preview from C++ Data Structures and Algorithms

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) { ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Data Structures and Algorithms Using C++

Data Structures and Algorithms Using C++

Ananda Rao Akepogu, Radhika Raju Palagiri
C++ Data Structures and Algorithm Design Principles

C++ Data Structures and Algorithm Design Principles

John Carey, Anil Achary, Shreyans Doshi, Payas Rajan
C++ Plus Data Structures, 6th Edition

C++ Plus Data Structures, 6th Edition

Nell Dale, Chip Weems, Tim Richards

Publisher Resources

ISBN: 9781788835213Supplemental Content