How Is it possible to access the private member of a base class in the derived class in c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How Is it possible to access the private member of a base class in the derived class in c++

3rd Jun 2021, 2:05 PM
steadson allen
steadson allen - avatar
1 Answer
+ 1
#include <iostream> using namespace std; class A{ private: int x = 10; public: void show(){ cout<<x; } }; class B:public A{}; int main() { B b; b.show(); return 0; }
3rd Jun 2021, 2:10 PM
TOLUENE
TOLUENE - avatar