inherits the base class virtually, then the pure virtual method does not need to be defined in that deriving class. However, if the deriving class does not inherit the base class virtually, then all virtual methods must be defined. The code below may be explored interactively here.#include <string> #include <iostream> class A { protected: std::string _msg; public: A(std::string x): _msg(x) {} void test(){ std::cout<<"hello from A: "<<_msg <<"\n"; } virtual void pure_virtual_test() = 0; }; // since B,C inherit A virtually, the pure virtual method pure_virtual_test doesn't need to be defined class B: virtual public A { public: B(std::string x):A("b"){} }; class C: virtual public A { public: C(std::string x):A("c"){} }; // since B,C inherit A virtually, A must be constructed in each child // however, since D does not inherit B,C virtually, the pure virtual method in A *must be defined* class D: public B,C { public: D(std::string x):A("d_a"),B("d_b"),C("d_c"){} void pure_virtual_test() override { std::cout<<"pure virtual hello from: "<<_msg <<"\n"; } }; // it is not necessary to redefine the pure virtual method after the parent defines it class E: public D { public: E(std::string x):A("e_a"),D("e_d"){} }; int main(int argc, char ** argv){ D d("d"); d.test(); // hello from A: d_a d.pure_virtual_test(); // pure virtual hello from: d_a E e("e"); e.test(); // hello from A: e_a e.pure_virtual_test(); // pure virtual hello from: e_a } References Class (computer programming) C++ sv:Multipelt arv tr:Çoklu kalıtım