Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!wuarchive!uunet!zephyr.ens.tek.com!uw-beaver!milton!sumax!polari!rwing!seaeast!sunbrk!Usenet From: Struan.Judd@sunbrk.FidoNet.Org (Struan Judd) Newsgroups: comp.lang.c++ Subject: Re: Proposal: 'virtual' class members for C++ Message-ID: <675518012.34@sunbrk.FidoNet> Date: 28 May 91 04:12:39 GMT Sender: Usenet@sunbrk.FidoNet.Org Lines: 55 Reply-To: struan@fivegl (Struan Judd) In article <1991May24.170014.17301@kestrel.edu> gyro@kestrel.edu (Scott Layson Burson) writes: >In article <1745@culhua.prg.ox.ac.uk> bill@robots.oxford.ac.uk (Bill Triggs) writes: >>I would like to propose a simple extension of C++ syntax >>which would allow 'soft' or 'virtual' class members to be >>simulated by member functions. >> >>[...] > >I like the basic idea of having things that look like member variables >that are actually member function invocations. However, I don't like > >[...] > >-- Scott >Gyro@Reasoning.COM Throwing my $0.02 into the ring on this general subject, I quite like using the following style. While it does not hide the fact that assignments to variables are being done through a function interface, it does allow non-friends of the class 'access' to some of the member variables of the class. Example: class Scr_Location { private: unsigned char SL_Left, SL_Top, SL_Right, SL_Bottom; public: Scr_Location(void); . . . const unsigned char &Left = SL_Left, &Right = SL_Right, &Top = SL_Top, &Bottom = SL_Bottom; . . . }; (Question: It would be very nice if C++ compilers could recognise this construct and not actually reserve storage in the class instances for the references. Do any do this?) This works for me as I tend to only have code executed when variable values are changed not when they are merely obtained. -- +------------------------------------------------+---------------------+ | Struan L. Judd | struan@fivegl.co.nz | | Of all the bit boxes in this electronic world, | PH: +64 9 302-1621 | | this message had to shift into this one. | FAX: +64 9 302-1617 | * Origin: Seaeast - Fidonet<->Usenet Gateway - sunbrk (1:343/15.0)