fork(3) download
  1. #include <iostream>
  2.  
  3. class Int
  4. {
  5. public:
  6. Int(const int& a) : integ(a) {}
  7.  
  8. friend std::ostream& operator<<(std::ostream& oss, const Int& rhs)
  9. {
  10. return oss << rhs.integ;
  11. }
  12. int operator+(Int o){return integ+o.integ+1;}
  13.  
  14. private:
  15. int integ;
  16. };
  17.  
  18. int main()
  19. {
  20. Int two = 2;
  21. std::cout << two << " + " << two << " = " << two + two;
  22. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
2 + 2 = 5