This one is really crazy cause i think my professor screwed it up. I have to write a class Bank. It contains objects savings of class Account. now say i have a savings array and a savings object has
Account savings = new Account[5];
//How do i return the following:
savings[0].customer;
The problem is that customer is a private member of class Account. The text says my function must return savings[pos].customer. Otherwise it should return a blank string "".
For convinience, heres is the code:
const char * Bank::getCustomer(int pos) const{
if (pos < size){
return savings[pos].customer;
} else {
return "";
}
}
const char * Bank::getAccountNumber(int pos) const{
if (pos < size){
return savings[pos].accountNumber;
} else {
return "";
}
}
int Bank::getBalance(int pos) const{
if (pos < size){
return savings[pos].balance;
} else {
return 0;
}
}
For people who would like to go through the code:
Bank Class Header and Definition