In C++, RTTI (Run-time type information) is available only for the classes which have at least one virtual function. For example, dynamic_cast uses RTTI and following program fails with error "cannot dynamic_cast `b' (of type `class B*') to type `cla…
在前面已经探讨过了虚继承对类的大小的影响,这次来加上虚函数和虚继承对类的大小的影响. 先来回顾一下之前例子的代码: #include <iostream> using namespace std; class BB { public: int bb_; }; class B1 : virtual public BB { public: int b1_; }; class B2 : virtual public BB { public: int b2_; }; class DD : public…