I must have accidentally omitted the list in this reply, perhaps
others are interested...
Bohan Liu <
[hidden email]> writes:
> e.g. observerable1 = observerable2, normally, observerable2 is assigned to
> observerable1. However, in the case of QuantLib, observerable2 is not
> assigned to observerable1, which will keep it's orginal state.
That is not necessarily the case since derived classes can implement
assignment and copy their state across.
> Q1: So in this case, now that nothing has changed, why is it necessay to
> notifyObservers()?
As noted in the comments, in this particular case of the assignment
operator, the notifyObservers() will not be very useful because
without explicitly defined derived assignment operators it will be
called before the actual assignment.
However, the general principle is that derived classes will have a
non-trivial assignment and although observers are not copied over,
they should call notifyObservers() nevertheless to notify their
already existing observers.
> Q2: If you do not want observerables to be copied, why don't you simply only
> declare the function prototype without definition, like what you did for the
> copy constructor?
[Actually, the definition exists, it is just empty.] The difference is
that newly created object can not have observers while an object being
assigned to can have existing observers.
Hope that helps,
Best,
Bojan
--
Bojan Nikolic ||
http://www.bnikolic.co.uk--
Bojan Nikolic ||
http://www.bnikolic.co.uk------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.
http://p.sf.net/sfu/bobj-july_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users