Subscribe Us

Responsive Advertisement

Advertisement

oop protected access modifier in inheritance

 

oop protected access modifier in inheritance





#include<bits/stdc++.h>

using namespace std;

class person

{

protected :

    string name;

public :

    void setname(string s)

    {

        name=s;

    }




};

class student : public person

{

public :


    void diplay()

    {

        cout<<"name : "<<name<<endl;

    }

};

int main()

{

    student s1;

    s1.setname("Ujjal Roy");

    s1.diplay();




    return 0;

}


Post a Comment

0 Comments