Results 1 to 5 of 5

Thread: c++ question what does this mean?

  1. #1
    Member Newbie
    Join Date
    Mar 2002
    Location
    pittsburgh
    Posts
    44

    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
    Senior Member Regular Contributor
    Join Date
    Sep 2000
    Location
    Vancouver BC Canada
    Posts
    417

    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
    Member Newbie
    Join Date
    Mar 2002
    Location
    pittsburgh
    Posts
    44

    Re: c++ question what does this mean?

    thanks

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

    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,753

    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

Similar Threads

  1. Replies: 5
    Last Post: 04-23-2018, 12:03 AM
  2. Texture question and sphere question...
    By detzel in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-19-2001, 12:02 PM
  3. Matrix question (Not really an OGL Question)
    By KurtCob in forum OpenGL: Basic Coding
    Replies: 22
    Last Post: 04-04-2001, 07:55 AM
  4. Quake3 bsp question (not really openGL question)
    By ribblem in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 01-15-2001, 10:13 AM
  5. Replies: 2
    Last Post: 01-08-2001, 03:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean