Why do I have to specify virtual functions in the declaration of a derived class?

Posted by neuviemeporte on Stack Overflow See other posts from Stack Overflow or by neuviemeporte
Published on 2010-04-19T10:35:30Z Indexed on 2010/04/19 10:53 UTC
Read the original article Hit count: 254

Filed under:
|
|

Given the base class A and the derived class B:

class A {
public:
  virtual void f();
}

class B : public A {
public:
  void g();
}

I get errors saying that f() is not declared in B while trying do define void B::f(). Do I have to declare f() explicitly in B? I think that if the interface changes I shouldn't have to correct the declarations in every single class deriving from it. Is there no way for B to get all the virtual functions' declarations from A automatically?

© Stack Overflow or respective owner

Related posts about c++

Related posts about virtual