Thread: I can't understand some operators

  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, 07: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, 04:37 AM
  4. floating point operators
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 10-22-2003, 07:53 PM
  5. Operators
    By George in forum C++ Programming
    Replies: 3
    Last Post: 04-02-2003, 07:35 PM