About dynamic cast and address of base and derived objects

前端 未结 4 2006
名媛妹妹
名媛妹妹 2021-01-22 11:10

I was reading through some of effective c++ and I realized I may be incorrect in my thinking along the way.

class A
{
    public:
    void laka()
    {
        c         


        
4条回答
  •  忘掉有多难
    2021-01-22 11:11

    This is all compiler and implementation dependent. In your case a B is a A + something, so it sotres the A then the B specific members. so the address of &b and the one displayed by your dynamic_cast ought to be the same.

提交回复
热议问题