Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!hp4nl!media03!pkr From: pkr@media03.UUCP (Peter Kriens) Newsgroups: comp.lang.c++ Subject: Re: MEMBER ACCESS Message-ID: <2351@media03.UUCP> Date: 3 Jun 91 08:06:14 GMT References: <97edfa6b92f028446f60@rose.uucp> Reply-To: pkr@media03.UUCP (Peter Kriens) Organization: aQute, Netherlands Lines: 28 Ahh, somebody wants to add just one xtra keyword to th elanguage: > A class has certain data members, for efficiency reasons, I would like > to grant the USER read-only access. > EX: > class COORD > { > public: > // Don't modify just read.. > int x,y; > ... > }; I think this shows a bit the problem with C++, adding goodies to the language which are rarely really usefull and can be implemented perfectly with the language as it currently is. Jus specify two inline functions which return the values. Then you have got your read only access, and as an added benefit, if you later decide to keep you coordinate as a polar, then your existing users won't break. While if you had given them read access, you were forced to maintain those instance variables. And for performance, an inline function should be about equal in performance from giving access. Peter Kriens