fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. template<class T>
  7. class CFraction
  8. {
  9. public:
  10. CFraction(int = 0){}
  11. CFraction(const CFraction&) = default;
  12. CFraction& operator=(const CFraction&) = default;
  13.  
  14. template<class U>
  15. CFraction operator + (const CFraction<U>& value) const { cout << "C+C\n"; return *this; }
  16.  
  17. CFraction operator + (int value) const { cout << "C+i\n"; return *this; };
  18. };
  19.  
  20. int main(int argc, const char * argv[])
  21. {
  22. CFraction<int> a, b;
  23. a = a + b;
  24. a = b + 2;
  25. }
  26.  
  27.  
Success #stdin #stdout 0s 4328KB
stdin
Standard input is empty
stdout
C+C
C+i