|
Alas, I don't know why everyone likes to use the term virtual base class, but something like
class Base {
public: virtual void fun () = 0;
};
Such a class containing pure virtual functions should be called an abstract class instead of a virtual base class. The so-called virtual base class, such as the following
class A {....};
class B: virtual public A {....};
class C: virtual public A {....};
Here, A is called the virtual base class of B and C, because B and C use "virtual inheritance" when inheriting A. This inheritance method is used to prevent "diamond multiple inheritance" when multiple inheritance is used. such as:
class D: public B, pubilc C {....};
At this time, "virtual inheritance" can ensure that D saves only one member variable of A.
Ha ha, just be serious about the issues discussed, do n’t blame everyone |
|