Okay, so what is function getbalance()?
As I hinted above, it's function - and function has its return value. In this example, it looks like it has a value of int.
If you understand some of C++, then you might want to know that this function
probably looks like this:
1 2 3 4 5
|
//general definition; not including class
int getbalance()
{
return balance;
}
|
This way, this function only RETURNS something. You can't access balance variable, you can only see it(know what value it holds). To access it, you would either have to do:
|
accounts[loc].balance = accounts[loc].getbalance() + 10;
|
But mostly, if you have getter function like getbalance(), you won't be able to access balance directly. Therefore, you may hope(or just check) that this class has a setter, which you could use (probably)like this:
|
accounts[loc].setbalance( accounts[loc].getbalance() + 10 );
|