noobie question!

This is a discussion on noobie question! within the C++ Programming forums, part of the General Programming Boards category; what do the "?" and the ":" operator do? i know they are conditional but i am not sure on ...

  1. #1
    tetra
    Guest

    noobie question!

    what do the "?" and the ":" operator do? i know they are conditional but i am not sure on their uses or definition.


    any help is appreciated.

  2. #2
    Registered User Cela's Avatar
    Join Date
    Jan 2003
    Posts
    362
    It's just like an if/else statement except it can be used anywhere an expression can, this
    Code:
    x = (x != 0) ? a : b;
    Is functionally the same as this
    Code:
    if (x != 0)
    {
      x = a;
    }
    else
    {
      x = b;
    }
    *Cela*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  2. A fourth noobie question - namespace std?
    By Noobie in forum C++ Programming
    Replies: 24
    Last Post: 08-12-2005, 02:10 PM
  3. another noobie question
    By noobie in forum C++ Programming
    Replies: 21
    Last Post: 01-21-2003, 01:04 PM
  4. A third noobie question
    By Noobie in forum C++ Programming
    Replies: 5
    Last Post: 01-20-2003, 11:53 PM

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