Michael_Hoennig@hh.maus.de (Michael Hoennig) (06/05/91)
Hi Phil, PC> A language feature I'd like to see... PC> PC> A class has certain data members, for efficiency reasons, I would like PC>to grant the USER read-only access. PC> PC> class COORD PC> { PC> public: PC> // Don't modify just read.. PC> int x,y; PC> ... PC> }; Try this: class COORD { int x, y; public: COORD() { x=0; y=0; } //... const int &theX() const { return(x); } const int &theY() const { return(y); } }; int main() { COORD aCoord; int x; x = aCoord.theX(); aCoord.theY() = x; return 0; } Bye -- Michael Hoennig -- Dobbelersweg 45 -- D-2000 Hamburg 26 -- ++49 40 219 24 58 office: mi1@starlab.UUCP -- ++49 40 23 08 56 (StarDivision Hamburg)