Bitset questions

This is a discussion on Bitset questions within the C++ Programming forums, part of the General Programming Boards category; Sorry to barge in, but how to convert a boolean to an integer? SK...

  1. #16
    Registered User
    Join Date
    May 2008
    Posts
    58
    Sorry to barge in, but how to convert a boolean to an integer?

    SK

  2. #17
    The larch
    Join Date
    May 2006
    Posts
    3,573
    I think a boolean already is an interger that has either the value 0 or 1.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #18
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by anon View Post
    I think a boolean already is an interger that has either the value 0 or 1.
    Yes, it should convert automatically to integer - or a cast will do the job.
    Code:
    static_cast<int>(somebool)
    [I think - I always get confused about the C++ casts]

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 09:47 AM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 06:36 AM
  3. Using bitset class inside another
    By Dhekke in forum C++ Programming
    Replies: 3
    Last Post: 07-26-2005, 07:50 AM
  4. Several Questions, main one is about protected memory
    By Tron 9000 in forum C Programming
    Replies: 3
    Last Post: 06-02-2005, 08:42 AM
  5. Trivial questions - what to do?
    By Aerie in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 12-26-2004, 09:44 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21