External read function

Nov 30, 2012 at 11:07pm
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
Dec 1, 2012 at 11:34am
bump
Dec 1, 2012 at 11:45am
And what is your question?
Dec 1, 2012 at 3:07pm
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 ....
}
Dec 1, 2012 at 5:36pm
Is account an existing class or something which you need to define also?
Dec 1, 2012 at 7:49pm
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
Dec 2, 2012 at 12:36pm
No one can help?
Dec 2, 2012 at 2:11pm
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.
Dec 3, 2012 at 2:45pm
I needs it to terminate when it sees the ">" char
Last edited on Dec 3, 2012 at 2:45pm
Topic archived. No new replies allowed.