From: D DOT J DOT Eleveld AT anest DOT azg DOT nl Newsgroups: comp.os.msdos.djgpp Subject: Re: enum problem Date: Wed, 17 Jun 1998 09:43:09 GMT Organization: Deja News - The Leader in Internet Discussion Lines: 54 Message-ID: <6m833d$lvq$1@nnrp1.dejanews.com> References: <19980615072556700 DOT AAA231 AT portC17 DOT Generation DOT NET> NNTP-Posting-Host: 192.87.23.66 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk In article , Eli Zaretskii wrote: > > > On Mon, 15 Jun 1998, sl wrote: > > > #include > > > > enum lineType > > { > > sLine=0x00, Are you sure you mean sLine = 0x00? > > dLine=0x01, > > overwrite=0x02, > > }; > > { > > saychoice(sLine|overwrite); > > } Are you trying to use the enum here like a bit field? Do you realize that sLine==0 which means that it has no bits set, so ORing with anything doesn't make a whole lot of sense. I would suggest (in C++): enum lineType { sLine = 1, dLine = 1<<1, overwrite = 1<<2 }; lineType operator|(const lineType one, const lineType two) { return lineType((int)one | (int)two); } Then you can do stuff like this: saychoice(sLine|overwrite) without any complaints from the compiler, and all your wierd casts are in one easy to find and maintan place, where you user doesn't have to do the casts them selevs, and possibly get it wrong and confuse the hell out of everything... Doug Eleveld -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/ Now offering spam-free web-based newsreading