tampurus

3 Basic class program

Dec 2nd, 2021 (edited)
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class student{
  4.     int roll;
  5.     public:
  6.     void getdata() {
  7.         cout<<"enter your roll no ";
  8.         cin>>roll;
  9.     }
  10.     void display() {
  11.         cout<<"roll no "<<roll;
  12.     }
  13. };
  14. using namespace std;
  15. int main()
  16. {
  17.     student s;
  18.     s.getdata();
  19.     s.display();
  20.     return 0;
  21. }
  22. /*
  23. Output
  24. enter your roll no 5
  25. roll no 5
  26. */
Advertisement
Add Comment
Please, Sign In to add comment