Boost logo

Boost :

From: Larry Evans (jcampbell3_at_[hidden])
Date: 2002-08-21 06:13:33


Philippe A. Bouchard wrote:

>"Larry Evans" <jcampbell3_at_[hidden]> wrote:
>
>[...]
>
>
>
[snip]

>Thanks for pointing this one out; I was blinded with the main constructor (U
>*). I've uploaded a new version of ptr.hpp and your inherit2.cpp outputs:
>
>Btm typeid=0
>Mid<left> typeid=1
>Mid<right> typeid=2
>Top typeid=3
>inherit2_test for ptr
>dpB->b=10
>dpB->Mid<left>::m=7
>dpB->Mid<left>::t=6
>dpB->Mid<right>::m=9
>dpB->Mid<right>::t=8
>going up left branch:
>Mid<left>::m=7
>:spT->t=6
>going up right branch:
>Mid<right>::m=9
>:spT->t=8
>
>
>
>
Now try putting:

     SmartPtr<Mid<left> > spOM( spB );
     SmartPtr<Top> spOT( spOM );
just before:
      cout<<":spT->t="<<spT->t<<endl;
in print_t<right>. You should see the wrong value for spT->t. It will
give the value for the left branch. This is because the value for:
     

  ptr_base<Top,...>::s_offset[a_p.get_typeid()]

was reset by the spOM( spB ) constructor call to be valid for the left
branch.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk