A program showing the implementation of a simple class.

 

#include<iostream.h>
#include<conio.h>


class bank_account
{
public:
int account_no;
double balance;
double amount;
void deposite()
{
cout<<"Enter amount to be deposited:";
cin>>amount;
balance+=amount;
}
void withdrawn()
{
cout<<"Enter amount to be withdrawed:";
cin>>amount;
balance-=amount;
}
};

void main()
{
clrscr();
bank_account B1;
cout<<"Enter account no.: ";
cin>>B1.account_no;
cout<<"Enter balance: ";
cin>>B1.balance;
B1.deposite();
B1.withdrawn();
cout<<"\n**********************************"<<endl;
cout<<"\nAccount no.: "<<B1.account_no<<endl;
cout<<"Balance after money is deposited and withdrawed:"<<B1.balance<<endl;
gotoxy(25,24); cout<<"Press any key to continue......";
getch();
}

 

< Back