I have a class that only really ever needed by classes in a certain class hierarchy. I wanted to know if it is possible to nest the class in the highest class’s protected section and have all the other classes automatically inherit it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
‘Inherit’ is the wrong word to use since it has a very specific definition in C++ which you don’t mean, but yes you can do that. This is legal:
And code that is not in A or something that derives from A cannot access or instantiate A::Nested.