Code for Program that provides an example of class in C++ Programming
#include<iostream.h>
#include<conio.h>
class account
{
public:
int bal;
void deposit(int amt);
void withdraw(int amt);
void disp_bal();
};
main()
{
clrscr();
account a1,a2;
//accounts b1;
a1.bal=1000;
a1.deposit(300);
a1.withdraw(300);
a1.disp_bal();
a2.bal=500;
a2.deposit(200);
a2.withdraw(300);
a2.disp_bal();
}
void account::deposit(int amt)
{
bal=bal+amt;
}
void account::withdraw(int amt)
{
bal=bal-amt;
}
void account::disp_bal()
{
cout<<"Balance is : "<<bal<<endl;
}