3

Suppose I have a variadic method in a class called Base, which I overload in Derived. Calling the method of Base by using some variation of parameters not defined in Derived results in an error. Why?

Here is a working example:

struct Base
{
    template <typename... Args>
    void fun1(const Args&...) {}

    template <typename... Args> 
    void fun2(const Args&...) {}
};

struct Derived : public Base
{
    void fun1(int a) {}
};

int main() {
    Derived d;

    d.fun1(1); // Pass
    d.fun2(1,2); // Pass

    d.fun1(1,2); // Fail. Why?
    return 0;
}
quant
  • 21,507
  • 32
  • 115
  • 211

0 Answers0