Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Homework HelpRSS Feeds

Program that provides an example of class

Posted By: Dylan Bouchard     Category: C++ Programming     Views: 5908

Write a program that provides an example of class.

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;
}
  
Share: 


Didn't find what you were looking for? Find more on Program that provides an example of class Or get search suggestion and latest updates.

Dylan Bouchard
Dylan Bouchard author of Program that provides an example of class is from Montreal, Canada.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!