i dont know this solution…
for example, my code is,
class Bank
{
private :
list < Client*> clientList;
}
class Client
{
private :
list< Account*> accountList;
}
class account
{
private
list< string> statement;
}
oh, i want to access statement in bank class! and i think how to access its…
1) making list< Account*> getAccountList() method in Client class and list<string> getStatement() method in Account.
but why list is private? umm, may as well public?
2) making list access method(umm, for example, pop and push?) in All Class..
i got 2. but it’s terrible. I have a lot to do, and repeated similar function…
what is best way? it is way i never know?
The best solution is to have accessor methods in each class returning const reference to the list:
This is better than public because the returned list reference is not modifiable.
You could have methods returning const_iterator but then you must have methods on each class that return
begin,end, and any other list operations you expect you might need.