Which lines contain errors?

struct A {
    virtual void Foo(int) {}
    virtual void Foo(int, int) {}
    void Foo(int, int, int) {}
};

struct B : A {
    virtual void Foo(int) {}
};

int main() {
  B b;
  b.Foo(1);  // 1
  b.Foo(1, 2);  // 2
  b.Foo(1, 2, 3);  // 3
}
Explanation
Errors are in lines // 2 and // 3 because function B::Foo(int) hides other functions in scope of B. To use them you need to write in B: using A::Foo;

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes