Hi! I'm new to c++ and I'm following the examples of a book,but get stucked in this example using constructors... the compiler give me the following errors:
'saving_account' : undeclared identifier
' missing ';' before identifier 'acc1'
'acc1': identifier not found
CODE
//main
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void main()
{
int id;
double bal;
double rt;
cout << "\n Enter an id account: ";
cin >> id;
cout << "\n Enter balance: ";
cin >> bal;
cout << "\n Enter interest rate: ";
cin >> rt;
saving_account acc1(id, bal, rt);
}
//class declaration
class saving_account
{
private:
string id_no;
double balance;
double rate;
public:
saving_account(string, double, double);
double calc_interest();
};
saving_account::saving_account(string id, double bal, double rt)
{
id_no = id;
balance = bal;
rate = rt;
}
double saving_account::calc_interest()
{
return balance * rate;
}