Warning: overloaded virtual function "Base::process" is only partially overridden in class "derived"

c++, name-hiding, overriding, virtual-functions

Solution

The reason for the warning

Warning: overloaded virtual function "Base::process" is only partially overridden in class "derived"

is that you haven't overridden all signatures, you have done it for

virtual void process(int a,float b) {;}

but not for

virtual void process(int x) {;}

Additionally, when you don't override and don't use `using Base::process` to bring functions to scope the static calls to `derived::process(int)` won't even compile. This is because Derived has no `process(int)` at that case. So

Derived *pd = new Derived();
pd->process(0);

and

Derived d;
d.process(0);

won't compile.

Adding `using` declaration will fix this enabling for static call to hidden functions through pointer to Derived* and select operator d.process(int) to compile and for virtual dispatch (call to derived through base pointer or reference) to compile with no warnings.

class Base {
public:
    virtual void process(int x) {qDebug() << "Base::p1 ";};
    virtual void process(int a,float b) {qDebug() << "Base::p2 ";}
protected:
    int pd;
    float pb;
};

class derived: public Base{
public:
    using Base::process;

    /* now you can override 0 functions, 1 of them, or both
    *  base version will be called for all process(s) 
    *  you haven't overloaded
    */
    void process(int x) {qDebug() << "Der::p1 ";}
    void process(int a,float b) {qDebug() << "Der::p2 ";}
};

now:

int main(int argc, char *argv[])
{
    derived d;
    Base& bref = d;
    bref.process(1);    // Der::p1
    bref.process(1,2);  // Der::p2 
    return 0;
}

Problem

I am getting below warning . part of my code is : ``` class Base { public: virtual void process(int x) {;}; virtual void process(int a,float b) {;}; protected: int pd; float pb; }; class derived: public Base{ public: void process(int a,float b); } void derived::process(int a,float b){ pd=a; pb=b; .... } ``` I am getting below warning : ``` Warning: overloaded virtual function "Base::process" is only partially overridden in class "derived" ``` any way i have made process as virtual function so I am expecting this warning should not come ... What is the reason behind this ??

Original source

Related problems