A Smith and Wesson Beats Four Aces

Give up? Okay, here it is: When we create the file that contains the data for the HomeItem objects, we can start by writing the number of elements as the first line of the file. This is the solution we used to preallocate the m_Track vector that holds the track names for a "Music" HomeItem. The disadvantage of this solution is that it is harder to apply when the input file is generated directly by a human being, who is likely to make a mistake in counting the elements. However, this is not much of a drawback when we consider that the most common way to generate such a file in the real world is to create, edit, and delete items via a program. This program will read any pre-existing data file, allow modifications ...

Get Learning to Program in C++ 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.