Here I got compiling error while running the program. The program is as follows:
#include <iostream.h>
#include <conio.h>
class account
{
private:
int balance, c,d;
public:
account(int x)
{
if (x>=0)
{
balance=x;
}
else {
cout<<"Invalid entry\n your account balance has been set to 0\n";
balance =0;
}
}
void credit()
{
cout<<"Enter the amount you want to deposit:\n";
cin>>c;
balance=balance+c;
cout<<"You deposited.\n";
}
void debit()
{
cout <<"Enter the amount you want to draw:\n";
cin>>d;
balance=balance-d;
cout <<"You have withdrawn.\n";
}
void get_balance()
{
cout <<"Your Current Balance is:"<<balance<<endl;
}
};
void main()
{
int g,h,k,j;
char a;
clrscr();
cout<<"To create an Account-Account-1-Press a\n";
do
{
cin>>a;
if(a=='a')
{
cout <<"Enter the initial balance you want to deposit:\n";
cin>>g;
account (g);
}
else
{
cout<<"Invalid entry. Enter 'a' again\n";
}
}while (a!='a');
account one(g);
cout<<"To create an Account-Account 2- Press a\n";
do
{
cin>>a;
if(a=='a')
{
cout <<"Enter the initial balance you want to deposit\n";
cin>>h;
a2:;
account(h);
}
else
{
cout <<"Invalid entry.Enter 'a' again\n";
}
}while (a!='a');
cout <<"For deposit, withdrawal or balance inquiry of Account 1 Press 1, For account two Press 2.\n";
cin>>k;
switch(k)
{
case 1:
cout<<"For deposit Press 1\n For withdrawal Press 2\n For Balance Inquiry Press 3\n To go to the other account
<<Press 4\n To exit Press 5\n;
do
{
cin>>j;
switch(j)
{
case 1:
one.credit();
break;
case 2:
one.debit();
break;
case 3:
one.get_balance();
break;
case 4:
goto a2:;
case 5:
break;
default:
cout << "Not a number between 1 and 5!\n";
break;
}
return 0;
}
};
N.B: I am getting compiling error " functions containing do are not expanded inline"