const memberfunctions

From: Rutger van der Eijk (r36@nikhef.nl)
Date: Tue Aug 11 1998 - 14:10:07 MEST


Hi,

I couldn't find any reference on roottalk to this subject yet, so here I
go.

I noticed that in the root classes (including TObject) almost never
memberfunctions which don't (and shouldn't!) change datamembers of a class
are declared constant.
	For example most 'getters' should be declared constant (Except in
the exceptional case where you want a user of a class to be able to change
a datamember (which usually indicates an 'ill formed' (i.e. non OO)
program.)) Another example is for example the TObject::Print() member
which (at least in my opinion) should not change the object.
	Of course C++ does not force anyone to declare memberfunctions
constant if they in fact don't change the object. I do think it
is a sort of convention in structered/OO programming in C++ though. I see
that this might not be an issue of the highets priority but I think it
should be changed in the (near) future.

Anybody have (other) opinions about this?

Rutger



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:36 MET