Class definition including its members in C++
Class definition including its members
PROGRAM :-
#include<iostream.h>
class ABC
{
private: int data;
public: void getdata()
{
cout<<"Enter the number: ";
cin>>data;
cout<<""The number entered is:"<<data;
}
}
void main()
{
ABC obj;
obj.getdata();
}
Output :-
Enter number: 10
The number entered is : 10
PROGRAM :-
#include<iostream.h>
class ABC
{
private: int data;
public: void getdata()
{
cout<<"Enter the number: ";
cin>>data;
cout<<""The number entered is:"<<data;
}
}
void main()
{
ABC obj;
obj.getdata();
}
Output :-
Enter number: 10
The number entered is : 10
Comments
Post a Comment