Explore BrainMass
Share

What does this c++ code snippet mean?

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

Can someone please explain to me what does this c++ code snippet mean?

maxlen = (len1 > len2) ? len1 : len2;

I am confused, in general what does the question sign mean along with the statements in between parenthesis. I have seen this a lot and have no clue what it means.

© BrainMass Inc. brainmass.com March 21, 2019, 9:30 pm ad1c9bdddf
https://brainmass.com/computer-science/cpp/explaining-c-plus-plus-code-snippet-378516

Solution Preview

You can understand it as a compact if-then-else ternary operator "?:" .

In the given case it amounts to writing the following if-then-else ...

Solution Summary

In the given case it amounts to writing the following if-then-else statement.

$2.19