Like Tree5Likes

Help With Boolean Expressions

This is a discussion on Help With Boolean Expressions within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by Elysia I suppose I understand where you are coming from, but I think it would be better ...

  1. #16
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,302
    Quote Originally Posted by Elysia
    I suppose I understand where you are coming from, but I think it would be better to say that a null pointer is considered false. NULL is a null constant (which should not be used nowadays!) which should only be used with pointers, and as such, its meaning by itself should be "undefined."
    It would be better to say that, when converted to bool, zero evaluates to false and a null pointer evaluates to false.

    Quote Originally Posted by Elysia
    I cannot get if (!nullptr) to compile, however.
    There is a conversion from std::nullptr_t to bool, and "the operand of the logical negation operator ! is contextually converted to bool". Therefore, !nullptr should be valid, with a value of true.
    Last edited by laserlight; 02-25-2012 at 10:25 AM.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #17
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,020
    Well, Visual C++ doesn't like it. That's for sure.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

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

Similar Threads

  1. Expressions
    By DMEngOba in forum C Programming
    Replies: 2
    Last Post: 05-25-2009, 04:56 PM
  2. shortcutting in boolean expressions?
    By cyberfish in forum C++ Programming
    Replies: 17
    Last Post: 02-14-2008, 06:39 PM
  3. Liitle help with boolean expressions
    By Voyd in forum C++ Programming
    Replies: 2
    Last Post: 05-30-2006, 09:17 PM
  4. Replies: 4
    Last Post: 04-02-2004, 07:30 PM
  5. expressions
    By lizardking3 in forum Tech Board
    Replies: 5
    Last Post: 02-18-2003, 10:41 AM

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