Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unhide certain function with same name and different signature from base class in derived

class Base
{
public:
    virtual void f(int)
    {
        printf("Base f(int)\n");
    }

    virtual void f(int, int)
    {
        printf("Base f(int, int)\n");
    }
};

class Der : public Base
{
public:
    using Base::f;

    virtual void f(double)
    {
        printf("Der f(double)\n");
    }
};

So in this case I am able to use both functions from the base class. But is it possible to allow using in derived class only certain overloaded method from base? For example allow to use only f(int), but not f(int, int).

like image 367
Alecs Avatar asked Feb 22 '23 07:02

Alecs


1 Answers

It is not possible to unhide base class methods with the using directive selectively. Unfortunately, it's all or nothing.

like image 171
Tobias Avatar answered Apr 09 '23 00:04

Tobias