Hello ROOTers,
I have several questions about copy constructors and assignment
operators.
- Automatic copy constructor and assignment operator
ROOT classes have copy constructor and assignment operator which are
documented in html.
However some of them are not implemented in their sources nor headers.
For example,
http://root.cern.ch/root/htmldoc//TSpectrum.html#TSpectrum:operator=
Does this mean that copy constructors and assignment operators will
be created by compilers automatically ?
If so, it is very confusing if the automatic ones are listed in the
html document.
- Deep copy and shallow copy
As to TSpectrum, its assignment operator seems to copy objects as
'shallow copy' in spite of its pointer members.
Meanwhile e.g. TH1D has own (not automatic) assignment operator which
uses ::Copy() inside it.
What is the difference between these two coding styles ?
- assignment operator, copy constructor, Copy() and Clone()
How to determine appropriate copier from the above without reading
the ROOT source ?
Sincerely,
OKUMURA, Akira oxon_at_icrr.u-tokyo.ac.jp
Institute for Cosmic Ray Research, University of Tokyo
5-1-5 Kashiwanoha Kashiwa Chiba 277-8582 Japan
Phone/Fax : +81 4-7136-3153
Skype : okumura.akira
Received on Thu Jun 22 2006 - 08:52:11 MEST