Mail Archives: djgpp/1998/06/17/08:31:00
In article <Pine DOT SUN DOT 3 DOT 91 DOT 980615174251 DOT 11003B-100000 AT is>,
Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:
>
>
> On Mon, 15 Jun 1998, sl wrote:
>
> > #include <stdio.h>
> >
> > 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
- Raw text -