Nested Member In cpp

Nested Member In cpp

PROGRAM:

  1. #include<iostream>
  2. using namespace std;
  3. class student{
  4. char name[10];
  5. int roll_no;
  6. void print(){
  7. cout<<"\n\n Entered Name : "<<name<<"\n\n Entered roll no : "<<roll_no;
  8. }
  9. public:
  10. void setdata(){
  11. cout<<"\nEnter name : ";
  12. cin>>name;
  13. cout<<"\nEnter roll no : ";
  14. cin>>roll_no;
  15. print(); //!nesting of member function
  16. }
  17. };
  18. int main(){
  19. student s;
  20. s.setdata();
  21. return 0;
  22. }
  23.  

Comments

Popular posts from this blog

Introduction to ChatGPT: Explain what ChatGPT is, how it works, and what it is used for.

Multi Level Inheritance In cpp

Hybrid Inheritance In cpp