OOP C++ Classes

Pages: 12
@AbstractionAnon
Thanks! I think this is right in that scenario:

return (a + b > c && a + c > b && b + c > a) ? true : false;

Correct me if im wrong.
return a + b > c && a + c > b && b + c > a && a > 0 && b > 0 && c > 0;

You don't need a ternary operator.
Oh okay! Edited.
This obviously only returns 1 or 0, where would I include "boolalpha" in this case?
wirelesskill wrote:
This obviously only returns 1 or 0


No, it returns true or false (as long as the function had basic type bool).

Only when "cout <<"ing to a stream do true or false get written as 1 or 0.

Insert boolalpha into the output stream before the bool variable which you intend to output. Thus, e.g.,
cout << boolalpha << someBoolVariable;


DON'T include boolalpha anywhere in the function. The result is returned as a perfectly respectable bool.
Last edited on
@lastchance sorry, yeah, thats what I meant, its printing 0/1 in the output stream.
Thank you for this!
No worries - suddenly you are making very rapid progress! Good stuff!
Hah thanks! I guess. I was just having trouble understanding the process logically in my mind, once that clicked its kind of straight-shooting after that.
Topic archived. No new replies allowed.
Pages: 12