O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Example: A Linked List of Command-Line Arguments (Revisited)

By way of a concrete example and as an illustration using something you’ve seen before, let’s take a moment to create a simple linked list. This is perhaps one of the best ways to appreciate how classes can be used.

You’ll look at four main areas:

  • The node—storing the command and parameter

  • The list—storing the nodes

  • Adding a node

  • Searching for nodes

Note that this not a complete implementation; it is just an example to cover some of the basics of using classes in C++.

The Node

In a linked-list implementation, the node commonly contains some data specific to the application under development and a pointer to the next node in the list. The next node variable points to an instance of the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required