I can't understand some operators

This is a discussion on I can't understand some operators within the C++ Programming forums, part of the General Programming Boards category; Hello! I'd like to know what "?" and ":" function in the instruction below. int signal = x > y ...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    3

    I can't understand some operators

    Hello!

    I'd like to know what "?" and ":" function in the instruction below.

    int signal = x > y ? +1 : -1 ;

    Thank you! Bye!

    Silas Justiniano - Brazil.

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    int signal declares a variable
    = is assign men
    x > y is a condition
    ? asks if that condition is true
    +1 means that if the condition is true do this
    : seperates the true action from the false action
    -1 means that if the condition is false do this
    ; ends the command

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Logical Operators in C++
    By Flecto in forum C++ Programming
    Replies: 4
    Last Post: 05-15-2009, 08:17 AM
  2. Bolean Operators hurt my head. (Trouble understanding) :(
    By Funcoot in forum C++ Programming
    Replies: 3
    Last Post: 01-20-2008, 07:42 PM
  3. operators???
    By arjunajay in forum C++ Programming
    Replies: 11
    Last Post: 06-25-2005, 05:37 AM
  4. floating point operators
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 10-22-2003, 08:53 PM
  5. Operators
    By George in forum C++ Programming
    Replies: 3
    Last Post: 04-02-2003, 07:35 PM

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