Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: c++ question what does this mean?

  1. #1
    Intern Newbie
    Join Date
    Mar 2002
    Location
    pittsburgh
    Posts
    42

    c++ question what does this mean?

    z=z<0?0:z
    i know that this isnt an openGL question but it is in some opengl code that i am trying to incoorperate into my program. i know that it is an if else statement but am unsure of how to read it.
    incus

  2. #2
    Member Regular Contributor
    Join Date
    Sep 2000
    Location
    Vancouver BC Canada
    Posts
    433

    Re: c++ question what does this mean?

    z = z < 0 ? 0 : z

    is exactly equivalent to

    if (z < 0)
    {
    z = 0
    }
    else
    {
    z = z;
    }

  3. #3
    Intern Newbie
    Join Date
    Mar 2002
    Location
    pittsburgh
    Posts
    42

    Re: c++ question what does this mean?

    thanks

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,096

    Re: c++ question what does this mean?

    That one problem I have with C++ or OPP, to cryptic, sort of like short hand C.
    Also makes the programs hard to follow.




    Originally posted by rts:
    z = z < 0 ? 0 : z

    is exactly equivalent to

    if (z < 0)
    {
    z = 0
    }
    else
    {
    z = z;
    }


  5. #5
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,797

    Re: c++ question what does this mean?

    Huh? The ?: notation is a C thing, not C++. Has nothing at all to do with OOP. It's basically just a short-hand notation for if/then/else.
    Deiussum
    Software Engineer and OpenGL enthusiast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •