In this exercise we will try out the use of static members of a class. The problem is simpler to solve than to describe. Send me e-mail if you cannot follow the description.
When a new record is read in, we now wish to add it to an slightly extended set of records. Each record will now contain a unique student number as an integer field. When the set of students is read in we now assume that it is either an old set of records, without this new field or a set that has previously been processed to add the field. An old record set can be identified by checking to see if it starts with a number. If it does not start with a number, it is an old set.
If it does start with a number, this is the highest number allocated to a student in the set being read. Each record now has the individual student record number immediately after the student's name.
Your program should now have two phases. The first checks for new format records and processes these. If there are no new format records it moves to phase two. If there are, it reads them in and then switches to phase two.
Phase two processes old format records, either reading from the file, if there were no new format records, or, if there was a set of new format records in phase one, now adding new records from standard input. For each record added in this phase a new identification number should be added, starting with the highest one previously allocated or zero, as appropriate.
The highest allocated number so far should be stored as a class static member and accessed by class static member functions, with suitable protection levels to avoid interference.
This program is much simpler than its description here, honestly.
Test your new class with suitable data, both with lists of pure old records, pure new records and with new records followed by addition of additional records.
I will post my solution to these when PAD starts.