I am a beginner and I am using the concept of constructors to make a code that imitates like a banking software, when I execute the code, it going to the output screen and when I input something it comes back to the input screen. I have faced this problem a while ago and, in different programs when i am trying to use constructors. Thank for your help in advance.
#include<iostream.h>
#include<conio.h>
class account
{
public:
int i, j, count, d, sum;
struct bank
{
int deb[5];
int cre[5];
};
bank b;
account()
{
int deposit();
int credit();
int balance();
}
int deposit()
{
cout << "Enter the amount you want to deposit: ";
i = 0, count;
cin >> b.cre[i];
i++;
d = totaldep();
cout << "Total deposit is: " << d;
return 0;
}
int credit()
{
cout << "Enter the amout you want to take: ";
j = 0;
cin >> b.deb[j];
j++;
balance();
return 0;
}
int balance()
{
cout << "The balance is " << d - b.deb[j];
return 0;
}
int totaldep()
{
for (count = 0; count <= i; count++)
{
sum = sum + b.cre[count];
}
return sum;
}
};
void main()
{
account a;
clrscr();
getch();
}