Passing array into functions
Posted on 2005-04-28
Hey everyone, ive wrote a program to simulate bank balances etc, i've managed to write some code into main() to add up all the balances etc. :
int totalBalance = 0;
bankarray = BankAccount (1000,100.10);
bankarray = BankAccount (2000,200.20);
bankarray = BankAccount (3000,300.30);
bankarray = BankAccount (4000,400.40);
for (int i = 0; i < 4; i++)
totalBalance += bankarray[i].getBalance();
cout << "Total of balances in array : $" << totalBalance << endl;
This works abolsiutly fine.
Im just wondering how i can pass a bankarray to a function, ive tried defining it as :
int getTotal(bankarray, int number);
for the bank array, size of array etc. but its not working. Ive also tried a normal array but that'll obviously wont work. Can anyone help please?