about inheritance in C++, can a derived class get implemetation from base class without explicitly defining it -
the following has error
error lnk2001: unresolved external symbol "public: virtual void __thiscall c::foo(void)" (?foo@c@@uaexxz)
so c::test() cannot inherit implementation of b::test() automatically , have explicitly write everytime in c++?
class { public: virtual void foo()=0; virtual void test()=0; }; class b: public { public: virtual void foo(); virtual void test()=0; }; void b::foo() { } class c: public b { public: void foo(); void test(); }; void c::test() { }
if derived class declares virtual method parent class, c void foo(), must implement too. if want inherit b's implementation, don't declare void foo() in c.
class c: public b { public: void test(); };
Comments
Post a Comment