View Full Version : c++ question what does this mean?
incus
11-26-2002, 05:04 PM
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
z = z < 0 ? 0 : z
is exactly equivalent to
if (z < 0)
{
z = 0
}
else
{
z = z;
}
incus
11-26-2002, 05:15 PM
thanks
nexusone
11-27-2002, 04:41 AM
That one problem I have with C++ or OPP, to cryptic, sort of like short hand C.
Also makes the programs hard to follow.
http://www.opengl.org/discussion_boards/ubb/smile.gif
Originally posted by rts:
z = z < 0 ? 0 : z
is exactly equivalent to
if (z < 0)
{
z = 0
}
else
{
z = z;
}
Deiussum
11-27-2002, 07:22 AM
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. http://www.opengl.org/discussion_boards/ubb/smile.gif
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.