Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

"class sample:private demo" what is wrong in this ?

+1 vote
asked Dec 27, 2018 by Neelima Vechalapu (190 points)

1 Answer

+1 vote
answered Jan 4, 2019 by Ryan (1,230 points)
Nothing should be wrong with that code you have given. The only issue would be if you didn't have a private section in the "demo" class because there would be nothing to inherit. Other than that possibility, this is a perfectly error-free derived class definition.
commented Jan 11, 2019 by Neelima Vechalapu (190 points)
Of-course you are right , but i think private members are not accessed directly.
I tried this program but it is shoing errors.
commented Jan 11, 2019 by Ryan (1,230 points)
Oh, I see what you're saying. You're right. Because the member functions are private, they can't be called by functions outside of the class. If your other code is attempting to do this, You would need a public member function in the demo class to call the private one.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...