External read function

I have this project where I have to make an external function read_account that allows you to read any type of bank account from an input stream, its signature must be:
istream & read_account(istream &in, account * & a)

It is supposed to be used as follows:

account *aa = 0;
while (read_account(cin, aa) && aa)
cout << *aa << endl;

I have different types of accounts basicly

account is name with money in $
account_euro is name with money in $ and euro
account_yen is name with money in $ and yen
account_euro_and_yen is name with money in $, yen and euro

the input i need to have is
<acccount of: john $: 100 > // normal account or
<account of: steven $: 100 E: 250 > // account with euro and so on
And what is your question?
The question is how to make the function work, I dont know what to put inside it.

istream & read_account( istream & in, account * & a ) {

// magic ....
Is account an existing class or something which you need to define also?
It is an existing class
base class: account
derived classes: account_yen/account_euro/account_euro_and_yen

i've made also a virtual member function that checks objects and gives true/false if the class has email or telephone or both
No one can help?
Does the input file look exactly like this:
<acccount of: john $: 100 >
<account of: steven $: 100 E: 250 >

will the '<' and '>' symbols appear in the file?

Basically, you just need to define the format of the input data, then read each line and interpret the various fields.
I needs it to terminate when it sees the ">" char
Last edited on
Topic archived. No new replies allowed.