2
class Base
{
public:
    virtual void SetValue(int v)
    {
        a = v;
    }

    void SetValue(std::string str)
    {
        b = str;
    }

    void SetValue(bool val)
    {
        c = val;
    }

private:
    int a;
    std::string b;
    bool c;

};


class Derived : public Base
{
public:
    virtual void SetValue(int v) override
    {
        //
    }
};




int main()
{

    Derived d;
    d.SetValue("string"); // cant use string as argument

}

In base class, i have two methods with same name and also with one virtual method with the same name. If i override the SetValue virtual method from base class, i cant able to use the other two non virtual methods from base class when i instantiate the derived class. Is this the default behaviour of overloading and overriding methods?

S.Frank Richarrd
  • 488
  • 1
  • 3
  • 15

0 Answers0