3 ms·
Huh. Does that mean I can write class A { public: virtual void foo() = 0; }; void A::foo() {} class B: public class A {}; B b;
by anon4 11y ago
Huh. Does that mean I can write
class A {
public:
virtual void foo() = 0;
};
void A::foo() {}
class B: public class A {};
B b;
b.foo();
and that will work?
- pbsd 11y agoNo, it will complain that A::foo is pure virtual, and that B must implement `foo`. However, if you define in B the method `void foo() { A::foo(); }`, it will work. In destructors this happens implicitly. There was an old Herb Sutter GotW about this: http://www.gotw.ca/gotw/031.htm http://www.gotw.ca/gotw/031.htm