I'll explain in the following the only strategy I'm immediately seeing for creating a new record in synchronized arrays and just wondered if that's the standard way to do it, as my strategy feels a little tedious.
I think it's probably easier to explain this without posting the complete code. So, here goes: Let's say you have some number of arrays ordered so that one index corresponds to 1 record across the various arrays (I'm calling that "synchronized arrays" in the hope that that name describes the problem). And now in the program, the user has a choice to keep adding one record across the whole groups of arrays as many times as she wants to.
For simplicity's sake, I'll just say there are 2 arrays here, which I'll call QtyList and TitleList, which can be defined with pointers as:
int * QtyList;
char * TitleList;
Now, if all of the arrays had the form of QtyList, we could just make them vectors rather than arrays and be done with it. And I suppose it's also possible to do that with TitleList, but let's just say we're doing it with arrays rather than vectors (I'm in Gaddis, chap. 9 at this point, and I feel sure that he wants the problem approached in this way).
Further let's suppose that Num is an integer variable whose current value is the number of rows that QtyList and TitleList have, and that TitleLength is a const int that determines how wide a title is allowed to be.
Here's my strategy for adding a new record to these arrays:
1) Generate 2 duplicate arrays with
int * QtyListOld = new int[Num];
char * TitleListOld = new char[Num*TitleLength];
then fill in the array values to make them the same as the arrays we already have.
2) In order to allow the original pointers to hold both the old values and the new value that the user is getting ready to enter, we now delete the original pointers with
delete [] QtyList;
delete [] TitleList;
3) We now generate new pointers for the original arrays with
QtyList = new int[Num + 1];
TitleList = new char[(Num + 1) * TitleLength];
4) Fill in the pointers we just created with the values from QtyListOld and TitleListOld and the new row with values entered by the user.
5) delete QtyListOld and TitleListOld.
Is this the standard way to keep adding an arbitrary number of lines to synchronized arrays? Or is there something better? The only other way I can think of would be to give yourself some headroom when you make the original array and then only going through the process of duplication and deletion once you pass a certain number of lines.
Or does one normally just use vectors from the start? I ask because these data organization methods have to be important. It feels to me like Access (with which I'm a lot more familiar than C++) has to be doing something like that whenever a new record is created. btw, is Access written in C++?