card@ziggy.EDU (James Card) (10/21/90)
Is there any way of telling which side of the '=' a class [] operator is on? I was thinking of a possible application in which a disk file could be used as a virtual array. A constructor could be used to open the "virtual" array and a destructor would be used to close the "virtual" array. Using this scheme, object[] operations appearing on the left hand side of the '=' would cause a write to the associated file, and object[] appearing on the right hand side of the '=' would cause a read of the disk array. Thanks in advance, James Card
fuchs@it.uka.de (Harald Fuchs) (10/23/90)
card@ziggy.EDU (James Card) writes: >Is there any way of telling which side of the '=' a class [] >operator is on? I was thinking of a possible application in which >a disk file could be used as a virtual array. A constructor could >be used to open the "virtual" array and a destructor would be used >to close the "virtual" array. Using this scheme, object[] operations >appearing on the left hand side of the '=' would cause a write to the >associated file, and object[] appearing on the right hand side of the >'=' would cause a read of the disk array. class file; class fileref { friend file; file& f; unsigned long ix; fileref (file& ff, unsigned long i): f (ff), ix (i) {} public: fileref& operator= (char); // left hand side operator char (); // right hand side }; class file { public: file (const char* name); ~file (); fileref operator[] (unsigned long ix) { return fileref (*this, ix); } }; -- Harald Fuchs <fuchs@it.uka.de> <fuchs%it.uka.de@relay.cs.net> ...