I need some help here.

Damian damian.pop at gmail.com
Wed Aug 30 08:52:23 PDT 2006

Suppose I have a class like this:

class cl{
        char[][] _data;
        int _maxDataLength;
        char[][] data(){
            _return data;
        void data(char[][] d){
            _maxDataLength = calculateMaxDataLength(d);
            _data = d;
        int maxDataLength(){
            return _maxDataLength;
        int calculateMaxDataLength(char[][] data){
            // this takes time.

And in a function I do something like this:
// dClass is a global cl object.

    char[][] d = dClass.data;
    d[3] = "naranja";
    int dlength = dClass.maxDataLength;

then dlength won't be valid, since _data has changed but
_maxDataLength wasn't updated.

How can I avoid this?
I know that 

        int maxDataLength(){
            return calculateMaxDataLength(_data);            

will solve the problem, but I don't want to call 
calculateMaxDataLength if the intention is to to see 
the data without modifying it.


More information about the Digitalmars-d-learn mailing list