"Jerry Coffin" <jc*****@taeus.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Dave Moore wrote:
[ ... ]
No, this is not true ... concrete classes can certainly be used as
base classes in a properly designed C++ program.
How do you implement operator= safely for this situation?
Well, if your base class has a copy assignment that can throw, then you
cannot write a copy-assignment operator that satisfies the "strong
guarantee" wrt exception safety. There is of course also a item in Scott
Meyers "More Effective C++" entitled "Make all non-leaf classes abstract",
which refutes my claim. So, I probably over-qualified my initial statement
by saying "properly designed C++ program", because strong exception safety
might be a requirement for "proper design" in many cases.
The fact is that I myself do not require the strong guarantee for my own
applications (scientific, numerical programs for which I am currently the
only user), and so I don't always think in terms of strong exception safety.
I will consider myself reprimanded 8*).
Actually this brings up a question ... If all of the data members in a class
(including any base classes) are statically allocated objects of built-in
type (i.e. no pointers or ctors), then does the implicitly generated copy
assignment operator implicitly provide the strong guarantee? Or even
better, the no-throw guarantee? It seems like it should, because the "only
thing that can go wrong" during construction in such a case is a stack
overflow (in which case we are dead anyway), or am I oversimplifying things.
Dave Moore