For example, class Base has two public methods: foo() and bar(). Class Derived is inherited from class Base (I cannot modify this class, as its a in a library I use).
In class Derived (Its in my application), I want to make foo() public but bar() private. Is the following code the correct and natural way to do this? Instead of extending it, I am creating a object and accessing only the required methods.
class Base {
public void foo();
public void bar();
};
public class Derived {
private Base base;
public void bar() {
base.bar();
}
};