using constructor to initialize data
Heres some info on the problem.
the program has to read from a file (file contains information on
individuals bank accounts) and "As each data line is read (each line is a
persons bank account information) you should allocate a new record and
initialize the data". I want to store these lines of data from the file as
elements in an array. Hopefully you understand what I'm getting at. How can
I initialize the data im getting from the file without an array? Or how can
I do it with an array? Any ideas welcome. Some lines of data will require me to use a different constructor to initialize only 2 fields or a different constructor to initialize 3 fields.
Here is what I'm getting at....
My professor gave me this project and he has special rules that go along with it. I'm trying to initialize private members but there are no public methods of doing so. Only constructors can be used to initialize the data. There are 7 people that I have to keep bank accounts for. I have to read in the file and as I read each line of data (some lines contain and extra parameter like the balance left in an accout) I have to figure out how many parameters there are and judging by that.......I have to call the correct constructor to initialize the private members of a class called BankAccount. I'm trying to somehow use an array. Even if I create 7 objects.....i still have to initialize them right away and I cant since I didnt have a chance to read in the file. Any help would be appreciated.