Xref: utzoo comp.lang.c++:12099 comp.std.c++:708 Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!ncar!unmvax!uokmax!occrsh!fang!tarpit!osceola.cs.ucf.edu!ssd From: ssd@engr.ucf.edu (Steven S. Dick) Newsgroups: comp.lang.c++,comp.std.c++ Subject: Re: distinguishing operator[] on left and right Summary: another problem Message-ID: <1991Mar6.235058.3641@osceola.cs.ucf.edu> Date: 6 Mar 91 23:50:58 GMT Sender: news@osceola.cs.ucf.edu (News sysetm) Organization: engineering, University of Central Florida, Orlando Lines: 26 What if I have a [] operator that does something unusual to extract the data from the object... for instance, a bitfield... // interface parts only... class packedbits { public: packedbits(int size); int operator[](int index); void set(int index); void clear(int index); }; doit() { packetbits flags(100); if (flags[4]) // this works .... flags.set(4); // works--but ugly flags[4] = 1; // how can I make this work??? } Steve ssd@engr.ucf.edu