[ROOT] fixing the vector classes

From: Dave Casper (dcasper@uci.edu)
Date: Fri Aug 18 2000 - 11:24:08 MEST


	Hi,

I was looking through the source for Root's vector classes and would like to
propose a specific improvement.

These classes (e.g. TVector3) are essentially identical to those in CLHEP.
In my opinion the CLHEP vector classes are almost useless as foundation
classes because nothing is declared as virtual/protected.  Not even the
destructor, and every book on class design I've read says that destructors
for base classes should always be virtual.  This allows you to delete a
derived object using a pointer to the base object.  I've had real problems
using CLHEP's vector classes in my programs, which is a pity since
derivation is the heart and soul of a supposedly standard class library.  In
the end I've had to write my own vector classes in order to derive from
them.

Would it be possible to make TVector3 and TLorentzVector's methods virtual
(at least the destructors) and their data members protected instead of
private, so they are suitable for deriving user classes from?  I can't
fathom why CLHEP's vector classes weren't written this way in the first
place.  If it's to allow inlining them I think it was a poor decision to
sacrifice the power of subclassing for whatever marginal to non-existent
gains might be achieved.


Dave
dcasper@uci.edu



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:31 MET