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;
}
thanks
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:
[b]z = z < 0 ? 0 : z
is exactly equivalent to
if (z < 0)
{
z = 0
}
else
{
z = z;
}
[/b]
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.