Thread: Logical Operators in C++

  1. #1
    Registered User
    Join Date
    May 2009

    Logical Operators in C++

    Hi everyone,

    In C# there is a difference between logical (& |) and conditional (&& ||) boolean operators. The conditional operators (AND &&) and (OR ||) only evaluate the right operand if the left operand evalutes to TRUE or FALSE respectively.

    Are there also two kinds of boolean operators in C++ or are there only && and ||? And if so, are these just plain logical (i.e. both operands are always evaluated regardless of the value of the first one) or are they conditional?

    Thanks for the help,

  2. #2
    The larch
    Join Date
    May 2006
    It's the same.
    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. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    It's all the same.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Behavior's the same, but the names are different. && and || (and !) are the logical operators. & and | are bitwise operators, and they just happen to be usable for eager logical connection of booleans, too.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Registered User
    Join Date
    May 2009
    Thanks for the prompt answers, guys.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Codeblocks and logical operators
    By fhbwghads in forum C++ Programming
    Replies: 2
    Last Post: 12-07-2008, 05:22 AM
  2. Question about logical operators
    By JohnMayer in forum C Programming
    Replies: 3
    Last Post: 07-22-2002, 06:32 PM
  3. Relational and Logical Operators
    By GSLR in forum C Programming
    Replies: 2
    Last Post: 03-03-2002, 04:33 PM
  4. Logical Operators
    By E i F x 65 in forum C++ Programming
    Replies: 6
    Last Post: 01-24-2002, 08:45 AM
  5. logical operators
    By sballew in forum C Programming
    Replies: 4
    Last Post: 09-04-2001, 06:24 PM