#include<stdio.h>
 
template<typename T> T max(T a, T b)
{
  if(a > b)
    return a;
 
  return b;
}
 
template<typename T> void swap(T &a, T &b)
{
  T tmp = a;
  a = b;
  b = tmp;
}
 
class Vector_2d
{
public:
 
  Vector_2d(double x_, double y_)
  {
    x = x_;
    y = y_;
  }
 
  void Print()
  {
    printf("(%+.3f , %+.3f)", x, y);
  }
 
  double x;
  double y;
};
 
int main(void)
{
  // Verwendung von max.
 
  printf("%d\n", max(1, 4));  // Der Compiler ersetzt T durch int.
  printf("%f\n", max(2.0, 3.0));  // Der Compiler ersetzt T durch double.
 
  // Verwendung von swap.
 
  double x = 2.0;
  double y = 3.5;
  printf("x = %f, y = %f\n", x, y);
  swap(x, y);  // Der Compiler ersetzt T durch double.
  printf("x = %f, y = %f\n", x, y);
 
  Vector_2d v1(1.0, 2.0);
  Vector_2d v2(3.0, 4.0);
  printf("v1 = ");
  v1.Print();
  printf(", v2 = ");
  v2.Print();
  printf("\n");
  swap(v1, v2);  // Der Compiler ersetzt T durch Vector_2d.
  printf("v1 = ");
  v1.Print();
  printf(", v2 = ");
  v2.Print();
  printf("\n");
}

