C++: how to publicly inherit from a base class but make some of public methods from the base class p
- by powerboy
For example, class Base has two public methods: foo() and bar(). Class Derived is inherited from class Base. In class Derived, I want to make foo() public but bar() private. Is the following code the correct and natural way to do this?
class Base {
public:
void foo();
void bar();
};
class Derived : public Base {
private:
void bar();
};