daily pastebin goal
61%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. //#include "Wektor2D.h"
  3.  
  4. template <typename T>
  5. T max (T a,T b)
  6. {
  7.     if (a > b) return a;
  8.     else return b;
  9. }
  10.  
  11. template <typename T>
  12. class Wektor2D
  13. {
  14.     T x;
  15.     T y;
  16. public:
  17.     Wektor2D(const T &xx, const T &yy) : x(xx), y(yy){}
  18. };
  19.  
  20. class Complex
  21. {
  22. public:
  23.     double im, re;
  24.     Complex(double r, double i) : im(i), re(r){}
  25.     Complex(double r) : im(0), re(r){}
  26.     Complex(const Complex& other) : im(other.im), re(other.re){}
  27.     double module() const { return sqrt(im*im + re*re); }
  28.  
  29.     /*bool operator > (const Complex& b)
  30.     {
  31.         return module() > b.module();
  32.     }*/
  33. };
  34.  
  35. //template <>
  36. //Complex max(Complex a, Complex b)
  37. //{
  38. //  if (a.module() > b.module() )
  39. //      return a;
  40. //  else
  41. //      return b;
  42. //}
  43.  
  44.  
  45. void main()
  46. {
  47.     double a= max(3., 4.);
  48.  
  49.     Complex c = 1.;
  50.     Complex c2(0, 1);
  51.        
  52.     Wektor2D<int> w1(1,2);
  53.     Wektor2D<Complex> w2(c, c2);
  54.  
  55.     max(c, c2);
  56. }
RAW Paste Data
Top