Can you access protected data members in C++?

But they can be accessed by derived classes or child classes while private members cannot. A program that demonstrates accessing protected data members in a derived class in C++ is given as follows − The output of the above program is as follows. Now, let us understand the above program.
For More Information Please Refer:


You May Also Like to Read: