fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. template<typename T, T def_val>
  6. class MyInt
  7. {
  8. T val = def_val;
  9. public:
  10. operator T() const
  11. {
  12. return val;
  13. }
  14. };
  15.  
  16. int main()
  17. {
  18. using int10_t = MyInt<int, 10>;
  19.  
  20. int10_t x;
  21.  
  22. cout<<"x = " << x << endl;
  23.  
  24. cout<<"x + 100 = " << x + 100 << endl;
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
x = 10
x + 100 = 110