Import certain overloads of base class to private scope of derived

34 Views Asked by At

Using the using-directive I'm able to select a certain set of methods from the base class to put into a different access scope. Is this also possible for individual overloads of the method? Something like this:

Demo

#include <iostream>

class base {

public:
    auto print() -> void {
        std::cout << "Hello World" << std::endl;
    }
    auto something_else(int) -> void {
        std::cout << "Hello int stuff" << std::endl;
    }
    auto something_else(bool) -> void {
        std::cout << "Hello bool stuff" << std::endl;
    }

};

class derived : public base {
public:
    using base::something_else(bool);
private:
    using base::something_else(int);
};

int main() {
    derived d;

    d.print();
    d.something_else(2);
    d.something_else(true);
}
0

There are 0 best solutions below