Logical Operators in C++

This is a discussion on Logical Operators in C++ within the C++ Programming forums, part of the General Programming Boards category; Hi everyone, In C# there is a difference between logical (& |) and conditional (&& ||) boolean operators. The conditional ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    2

    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,
    Flecto

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,761
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    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!
    CornedBee

    "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
    Posts
    2
    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, 07: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, 07:24 PM

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