delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/16/14:31:31

From: Doug Eleveld <deleveld AT dds DOT nl>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: enum problem
Date: Mon, 15 Jun 1998 12:01:52 +0200
Organization: Rijksuniversiteit Groningen
Lines: 23
Message-ID: <3584F110.76F55ACA@dds.nl>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 980615093258 DOT 9030D-100000 AT is>
NNTP-Posting-Host: client36-38.oprit.rug.nl
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Eli Zaretskii wrote:

---snip---

> Also, I strongly suspect that the type of an expression "a|b" is an
> int, regardless of its value.  (Could any ANSI guru please confirm
> this?)

Yes, I C++ it does, and I expect in C also.  Almost all operations on
enums produce ints.  Except of course when there global operators in
scope like this:

enumtype operator|(const enumtype one, const enumtype two)
   {
   return enumtype((int)one|(int)two));
   }

There is a big thread in comp.lang.c++.moderated called 'C++ and enums'
which discuss this.  Go find it on dejanews.

Hope this helps,

Doug Eleveld

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019