Nested Member In cpp

Nested Member In cpp

PROGRAM:

#include<iostream>
using namespace std;
class student{
    char name[10];
    int roll_no;
    void print(){
    cout<<"\n\n Entered Name : "<<name<<"\n\n Entered roll no : "<<roll_no;
    }
public:
    void setdata(){
    cout<<"\nEnter name : ";
    cin>>name;
    cout<<"\nEnter roll no : ";
    cin>>roll_no;
    print(); //!nesting of member function
    }
};
int main(){
    student s;
    s.setdata();
return 0;
}

 
 

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