Thread: noobie question!

  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, 02:04 PM
  4. A third noobie question
    By Noobie in forum C++ Programming
    Replies: 5
    Last Post: 01-21-2003, 12:53 AM