In C++ we can extend (derive) a base class privately to a child class:
class Base
{
// ....
};
class Child : private Base
{
// ....
};
What is Java’s corresponding syntax ?
If Java hasn’t it, what do Java programmers?
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.
Java’s syntax for inheritance:
There is no private inheritance in Java. Java only has public inheritance. That is, you both inherit implementation and interface.
With private inheritance, you would only inherit implementation. It’s basically a more static form of composition, as far as I remember.
In most cases, you can use composition to do the same thing.