code.cpp 344 B

123456789101112131415
  1. /* There is a ?: operator in C++ and it's basic form is
  2. (condition) ? (something1) : (something2).
  3. To illustrate:
  4. if (condition)
  5. something1;
  6. else
  7. something2;
  8. Write a function that uses the ?: operator to
  9. return "yeah" if the condition is true, and "nope" otherwise.
  10. */
  11. std::string yeahNope(bool b) {
  12. return b ? "yeah" : "nope";
  13. }