Create simple class

Wednesday, October 07, 2015 Unknown 0 Comments


Make simple Class ...

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

Class test
{
     int a,b;    //member variable of class. .
    public:     //public section of class
          void getdata()
          {
                  cout<<"enter value of A and B : ";
                  cin>>a>>b;
           }
          void showdata()
           {
                 cout<<"A = "<<a;
                 cout<<"B = "<<b;
            }
};
Void main()
{
       test t1; //t1 object of class test...
       Clrscr();
       t1.getdata();    //call mathod of class using object of that class.....
      t1.showdata();
       Getch();
}

OUTPUT:-enter value of A and B : 10 20
A : 10 B : 20



To know about God and Godly University please click here : www.pbks.info

other programs.....
1.simple cpp program
2.simple class
3.add two numbers of class
show this all programs

0 comments: