Alf P. Steinbach wrote:
>
Use two classes ARef and ARefConst.
This is what I would like to avoid (otherwise all const members of Aref
should be duplicated in ArefConst). It must also be possible to replace
an ArefConst by an Aref, but using inheritance/virtual functions is not
an option because of performance reasons.
Actually in my program A is an array of numerical values, but in some
circumstances it is preferable to treat certain ranges of an array
separately. For this purpose I made a slice (Aref) class that references
an array and simply allows to index a range of elements in it, e.g. it
is possible to "name" elements 10..20 of an array and index them from 0..10.
There were no problems until I tried to make slices writeable.
Any suggestions for implementing this?