I have a few code snippets from a tutorial Im reading my friend gave me to learn c++, and a lot of it is written in shorthand but I cannot fully understand the shorthand code.

return c < Cnt ? &foo[c]:NULL;;


return (cc > 0 && cc <= mCnt)?&foo[cc-1]:NULL;

and this:

x = c < mCnt ? c + 1:0;

Thank you!

Recommended Answers

Are you having problems with the ternary operator?


Jump to Post

All 3 Replies

@gerrard4143 I sort of understand it, I just cannot translate those snippets.

Nevermind I figured it out. Thanks for the link!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.