Thread: Help With Boolean Expressions

  1. #16
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    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.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #17
    Join Date
    Oct 2007
    Inside my computer
    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.

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, 03: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, 08: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