fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class limit {
  5. int lim;
  6. int k;
  7. public:
  8. limit(int lim_, int k_) : lim(lim_), k(k_) {}
  9. friend ostream& operator<<(ostream& ostr, const limit& lim);
  10. };
  11.  
  12. ostream& operator<<(ostream& ostr, const limit& lim) {
  13. if (lim.k < lim.lim) {
  14. ostr << "none";
  15. } else {
  16. ostr << lim.k - lim.lim;
  17. }
  18. return ostr;
  19. }
  20.  
  21. int main() {
  22. cout << "Hello " << limit(1, 15) << endl;
  23. cout << "World " << limit(1, -1) << endl;
  24. return 0;
  25. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
Hello 14
World none