#include<iostream.h>
#include<conio.h>
class acc_class
{
private:
                int acc_no;
                float balance;
public:
                void getdata()
                {
                                cout<<"Enter the Account No to Acc1 Object:- ";
                                cin>>acc_no;
                                cout<<"Enter Balance:- ";
                                cin>>balance;
                }
                void setdata(int acc_in)
                {
                                acc_no=acc_in;
                                balance=0;
                }
                void setdata(int acc_in,float balance_in)
                {
                                acc_no=acc_in;
                                balance=balance_in;
                }
                void display()
                {
                                cout<<"Account No:- "<<acc_no<<endl;
                                cout<<"Balance:- "<<balance<<endl;
                }
                void money_transfer(acc_class &acc,float amount);
};
void acc_class::money_transfer(acc_class &acc,float amount)
{
                balance=balance-amount;
                acc.balance=acc.balance+amount;
}
void main()
{
                int trans_money;
                acc_class acc1,acc2,acc3;
                clrscr();
                acc1.getdata();
                acc2.setdata(10);
                acc3.setdata(20,750.5);
                cout<<endl<<"Account Information: "<<endl;
                acc1.display();
                acc2.display();
                acc3.display();
                cout<<endl<<"How much money to be transfered from acc3 to acc1:- ";
                cin>>trans_money;
                acc3.money_transfer(acc1,trans_money);
                cout<<endl<<"Updated Information about accounts: "<<endl;
                acc1.display();
                acc2.display();
                acc3.display();
                getch();
}
Advertisements