Q&A

Q1:Why should I create a linked list if an array will work?
A1: An array must have a fixed size, whereas a linked list can be sized dynamically at runtime.
Q2:Why do you separate the data object from the node?
A2: Once you get your node objects working properly, you can reuse that code for any number of objects that might want to live in a list.
Q3:If I want to add other objects to the list, do I have to create a new list type and a new node type?
A3: For now, yes. We'll solve that when we get to templates.

Get Sams Teach Yourself C++ in 24 Hours, Third Edition 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.