Small error

I got error ---- expected initializer before "void".Can anyone tell how to fix this error in line 37 ... ?

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
  #include<iostream>
using namespace std;

//BankAccount class
class BankAccount
{
// Declare private variables.
private:
int accNum;
float accBal;
float intRate;
int left;
//Declare of public member functions.
public:
void displayAccount();
BankAccount(int,float=0,float=0); /*Note that second
and third arguments
have default values if no value is received while object creation.*/
};
// Define constructor.
BankAccount::BankAccount(int num, float bal, float rate)
{
accNum = num;
accBal = left;
intRate = rate;
//Check if account number is valid.
if (accNum < 1000 || accNum>9999)
    {
    accNum = 0;
    }
}
// Function to print all information.
void BankAccount::displayAccount()

// main function.

void main()
{
int acc;
float bal, rate;
char choice;
//Accept account information till user chooses to exit.
do
{
cout << endl << "Enter the account number: ";
cin >> acc;
cout << "Enter the account balance: ";
cin >> bal;
cout << "Enter the interest rate: ";
cin >> rate;
BankAccount B(acc, bal, rate); /*The scope of
object 'B'is
limited to this loop for single itteration. Every itteration will create and destroy a new object 'B'.*/
B.displayAccount();
cout << "\nDo you want to enter more"<<
" accounts?(y/n)";
cin >> choice;
if(choice=='n'||choice=='N')
{
break;
return;
}
} while (1);
}

kavindu wrote:
Can anyone tell how to fix this error in line 37 ... ?

By fixing the error on line 33.


BTW, in c++ it is int main().


Any other error fixing will have to wait for indentation fixing.
Last edited on
Topic archived. No new replies allowed.