Re: [C++] Best Way to ++booleans?

From: Attila Feher (attila.feher_at_lmf.ericsson.se)
Date: 01/28/04

  • Next message: Martijn Lievaart: "Re: Learning borland."
    Date: Wed, 28 Jan 2004 14:58:48 +0200
    
    

    > "Chris Newton" <chrisnewton@no.junk.please.btinternet.com> wrote in
    > message news:bv6tmb$bm1$1@titan.btinternet.com...
    >> James Connell wrote...
    >>> thanks Cris! i'm still learning C++, didn't know you could overload
    >>> on enums. would that remove the object overhead as well?
    >>
    >> Yep, good trick, in'it? :-)
    >>
    >> And yes, it's overhead-free. Manipulating enums like this is really
    >> no different to writing a function that works on something like an
    >> int, and indeed it's quite likely that under the covers, that's
    >> exactly what it'll compile down to.
    >>
    > Can't you change the type for the enumerator too?

    There is a proposal, but in the current language you cannot. In C it is
    int, in C++ it is an integral type the compiler comes up with.

    --
    Attila aka WW
    

  • Next message: Martijn Lievaart: "Re: Learning borland."

    Relevant Pages

    • Re: using std::system
      ... > int main{ ... > string s; ... That won't even compile. ... If I were writing this, I wouldn't use IOStreams at all but rather the ...
      (alt.comp.lang.learn.c-cpp)
    • K&R beginner code query
      ... I'm trying to use K&R to learn C from but am having some trouble. ... int c, nl, nw, nc, state; ... straight out of the book yet it still won't compile, is there a more modern way ... of writing such statements I'm not aware of??? ...
      (comp.lang.c)
    • Parser
      ... In comp.programming I asked for advice for writing a parser. ... someone showed me wouldn't compile. ... int parser; ...
      (comp.lang.c)
    • Re: "EXT3-fs error" after resume from s2ram
      ... INT A disabled ... writing 0xe2000008) ... connection state: disconnected -> associated ... setting latency timer to 64 ...
      (Linux-Kernel)
    • Re: GCC difference in size of long int on Suse SLES9 / Suse Professional 10.0
      ... The kernel uses printf() with 'long int', ... I can't compile 'on-the-fly'. ... clashing with the hardware and any libs that you interact with. ... platform types build up their own int types. ...
      (comp.os.linux.development.apps)