Thread: <?= operator

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    People Love Me
    Join Date
    Jan 2003
    Posts
    412
    Sweetie, '?' is the ternary operator, otherwise known as the conditional operator. It's called 'ternary' because it works with THREE operands...unlike something like '+' which works with two: (x+y).

    Code:
         int x=2, y=5, z=0; //Our three operands
         z = (x > y) ? (x:y); //Assign z to the bigger one.
    This is the alternative to if/else statements: it reads: "If x > y, assign x's value to z. Else, assign z the value of y."

  2. #2
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    How does that work in the situation its being used here?

    Code:
    maxx <?= rt + tt
    if maxx is 0, assign it to rt + tt? I'm confused already.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  3. #3
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    How does that work in the situation its being used here?

    Code:
    maxx <?= rt + tt
    if maxx is 0, assign it to rt + tt? I'm confused already.

    It cant be != like dwks said though, because its in the third section of the for statement..
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. unary operator overloading and classes
    By coletek in forum C++ Programming
    Replies: 9
    Last Post: 01-10-2009, 02:14 AM
  2. Smart pointer class
    By Elysia in forum C++ Programming
    Replies: 63
    Last Post: 11-03-2007, 07:05 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Operator Overloading (Bug, or error in code?)
    By QuietWhistler in forum C++ Programming
    Replies: 2
    Last Post: 01-25-2006, 08:38 AM
  5. operator overloading and dynamic memory program
    By jlmac2001 in forum C++ Programming
    Replies: 3
    Last Post: 04-06-2003, 11:51 PM