A Program using access modifiers to display object details in C++

 A Program using access modifiers to display object details

Program :-

#include<iostream.h >
class ABC
{
 private:int number;
 protected:int data;
public: void getdata()
{
 cout<<"Enter first number: ";
cin>>number;
cout<<"Enter second number: ";
cin>>data;
}
void putdata()
{
cout<<"The first number entered is"<<number;
cout<<"The second number entered is"<<data;
}
}
void main()
{
ABC obj;
obj.getdata();
obj.putdata();
}

Output :-
Entered first number: 10
Enter second number: 20
The first number entered is 10
The second number entered is 20

Comments

Popular posts from this blog

How to make a snake game using notepad using html [ with pictures ]

How to " Shut down " your pc using notepad [with pictures]

How to make" web html page " just using notepad [ with pictures ]