Help with a homework error (missing identifier)

We're supposed to create a Bank Account class, with a few public functions, and a main function. The main function is supposed to use an array (professor said 2 for his own sake) and pass the array, a count of valid items in the array, and an integer (used for years) b/t 1 & 40 inclusive to a function that will calculate and display the value of each account in the array after the given years.

My problem is that last function, which I'll post here:

1
2
3
4
5
6
7
8
9
10
11
12
void interestTable(BankAccount[] array1, int acct, int time)
{
	for (int x=0; x<acct; x++)
	{
		double finalValue=array1[x]::balance;
		for (int y=0; y<time; y++)
		{
			finalValue=finalValue*array1[x]::annualRate;
		}
		cout<< "In " time "years, account # " array1[x]::acctNum "will have $" finalValue ".";
	}
}


I have the function listed in the class's pubic section as such:
void interestTable(BankAccount[], int, int);

I receive the following errors when attempting to compile, which mystify me as this is my first program in c++.

1>f:\project1_bankaccount_ch7.cpp(88): error C3861: 'interestTable': identifier not found
1>f:\project1_bankaccount_ch7.cpp(97): error C2146: syntax error : missing ')' before identifier 'array1'
1>f:\project1_bankaccount_ch7.cpp(97): error C3646: 'array1' : unknown override specifier
1>f:\project1_bankaccount_ch7.cpp(97): error C2062: type 'int' unexpected
1>f:\project1_bankaccount_ch7.cpp(97): error C2059: syntax error : ')'
1>f:\project1_bankaccount_ch7.cpp(98): error C2143: syntax error : missing ';' before '{'
1>f:\project1_bankaccount_ch7.cpp(98): error C2447: '{' : missing function header (old-style formal list?)

any help on shortening this list of errors would be most appreciated, as I've seen that fixing one error sometimes takes several off the list.
This

BankAccount[] array1
is incorrect parameter declaration. It is not C# where such syntax is used. In C++ you shall write

BankAccount array1[]
That and moving the method above my main() method solved most problems, along with some syntax errors in the cout. It compiles now, thanks. I have one more issue, if anyone would like to help.

Here is a method to enter in account data (number and balance) for a bank account:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 void BankAccount::enterAccountData()
{
   char choice;
   const char quit = 'Q';
   cout << "Please enter your account number > " << endl;
   cin >> choice;
   while (choice != quit)
   {
     if (choice >= 1000)
	   {
		this->acctNum = choice;
		cout << "Please enter your account balance" << endl;
		cin >> choice;
		if (balance > 0)
		  {
		  this->balance = choice;
		  choice = quit;
		  }
		else
		  {
		    cout << "Please enter a valid, non-negative account balance" << endl;
		    cin >> choice;
		  }
	   }
	 else
	   {
		   cout << "Please enter a valid account number" << endl;
		   cin >> choice;
	   }
  }
}


It still compiles, and it behaves properly for an invalid account number (a non-number or a number < 1000), but if I give it a proper number, I receive "Please enter a valid account number" for 4 lines before asking for another input. I cannot find the logic in my coding that causes this.
Topic archived. No new replies allowed.