What 's wrong in this code ? I think in Inheritance I can use the protected data of other classes . | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What 's wrong in this code ? I think in Inheritance I can use the protected data of other classes .

#include<iostream> using namespace std; class code { protected: void jaat(){ cout<<" Haaa "<<endl; } public: void showdata() { cout<<" Hello " <<endl; } }; class mukul:public code{ public: void godata(){ cout<<"Mukul Nain "<<endl; }}; int main (){ mukul obj; obj.jaat(); obj.showdata(); cout<<"\n"; obj.godata(); return 0; }

27th Dec 2020, 3:45 AM
MUKUL Choudhary
MUKUL Choudhary - avatar
0 Answers