fork download
  1. #include <cstdio>
  2. #include <cstdlib>
  3.  
  4. template <class T>
  5. class number {
  6. public:
  7. T x;
  8. T y;
  9.  
  10. number (int a, int b){
  11. x=a; y=b;}
  12. int add (T&);
  13. T greater ();
  14. };
  15.  
  16. template <class T>
  17. int number<T>::add (T& rezAdd){
  18. rezAdd = x+y;
  19. return 1;
  20. }
  21.  
  22. template <class T>
  23. T number<T>::greater (){
  24. return x>y? x : y;
  25. }
  26.  
  27.  
  28. int main (int argc, char **argv) {
  29. int aux;
  30. number<int> c(3,5);
  31.  
  32. c.add(aux);
  33. printf ("number added [%d]\n", c.add(aux));
  34. printf ("greater number: [%d]\n", c.greater());
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
number added [1]
greater number: [5]