Yahoo Telephonic interview questions

Design classes for the following problem. (C++)
A Customer Can have multiple bank accounts A Bank account can be owned by multiple customers When customer logs in he sees list of account, on clicking on an account he sees list of transactions.

Solution :
Customer class, Account class, Transaction class
Customer class contains an array of pointers to the account classes
Account class contains an array of pointers to its owner customer classes
Account class also contains an array of transactions associated to it.
Transaction class contains id or pointer the customer who did that transaction
In customer class write a function with prototype

for (i in Accounts )
cout << i.AccountName << endl;
cin >> id;
for(i in Accounts[id].transactions )
cout << i.TransDetails << endl;

No comments: