Friday, August 7, 2015

Class Demonstartion

class Dummy
{
private:int a,b;         // DATA MEMBERS
public:
void getdata()          // MEMBER FUNCTIONS
{
cout<<"Enter the values";
cin>>a;
cin>>b;
}
void display()
{
cout<<"The value of a is"<<a;
cout<<"The value of b is"<<b;
}
};//closure of the class
void main()
{
Dummy D;// class instantiation
D.getdata();// invoking the member function of the class via an Object of the class
D.display();
}

No comments:

Post a Comment