Is there a more concise way to write the following C++ statements:
int max = 0;
int u = up();
if(u > max)
{
max = u;
}
int d = down();
if(d > max)
{
max = d;
}
int r = right();
max = r > max ? r : max;
Specifically is there a way to embed the assignment of the functions return inside the if statement/ternary operator?
Assuming that:
u,d,rlater on)… then you can just use
std::max:If this is the return value of the function:
Note that that can evaluate the functions in any order, rather than the string up, down, right order in your original code.