dynamic_cast of “this” inside constructor
问题 This question is very similar to this one Why can't I dynamic_cast "sideways" during multiple inheritence?, except that the cast does work - just not inside in the constructor. Header: class A { public: virtual ~A() {} void printA(); }; class B { public: B(); virtual ~B() {} void printB(); private: std::string message_; }; class C : public A, public B { public: C() {} virtual ~C() {} }; Source: void A::printA() { cout << "A" << endl; } B::B() { A* a = dynamic_cast< A* >( this ); if ( a ) {