Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2008-03-26 13:43:37


If this is what your want to do I think you would be better off with

lass Base {
    ...
    virtual ..
}
class D1 : public Base {
}

Base* bp1 = new D1(..some thing..);
Base* bp2;

ar << bp1;
ar >> bp2;

this might require registration or export though.

Robert Ramey

  "Andrei Popa" <andrei4popa_at_[hidden]> wrote in message news:BAY103-W307EA1D4D6FF4BE9CAB5C7E0FF0_at_phx.gbl...
  Robert Ramey wrote:
> Oh, that should be easy:
>
> D1 *d1p;
>
> ar << d1;
> ar >> *d1p;
>
> Robert Ramey

  Hi,

  At
> ar << d1;
> ar >> bp; // but "bp" points already to an object of type D1

  I meant : "bp" is "Base* bp"
  So, if I call ar >> *bp; the Base::load will be called, not the derived D1:load.

  Actually more precisely, I intend to do so

lass Base { ... virtual ..}class D1 : public Base {}Base* bp1 = new D1(..some thing..);Base* bp2 = new D1(..some thing else..);
  ar << *bp1;
  ar >> *bp2;

  This means for all my serializable classes I have a kind of "=" operator defined.

  regards,
  Andrei

------------------------------------------------------------------------------
  Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it!

------------------------------------------------------------------------------

  _______________________________________________
  Boost-users mailing list
  Boost-users_at_[hidden]
  http://lists.boost.org/mailman/listinfo.cgi/boost-users



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net