#include<math.h>
#include<stdio.h>
 
template<typename T> class Vector_2d
{
public:
 
  Vector_2d(T x_, T y_)
  {
    x = x_;
    y = y_;
  }
 
  T norm()
  {
    return sqrt(x*x + y*y);	
  }
 
  void Print();
 
  T x;
  T y;
};
 
template<typename T> void Vector_2d<T>::Print()
{
  printf("(%+.3f , %+.3f)", (double)x, (double)y);
}
 
int main(void)
{
  Vector_2d<float> v1(1.0, 2.0);  // Der Compiler legt v1 als float-Vektor an.
  printf("v1 = ");
  v1.Print();
  printf("\n");
  printf("norm(v1) = %+.5f\n", v1.norm());
  printf("norm(v1) = %+.10f\n", v1.norm());
  printf("sizeof(v1) = %zu\n", sizeof(v1));
 
  Vector_2d<double> v2(1.0, 2.0);  // Der Compiler legt v2 als double-Vektor an.
  printf("v2 = ");
  v2.Print();
  printf("\n");
  printf("norm(v2) = %+.5f\n", v2.norm());
  printf("norm(v2) = %+.10f\n", v2.norm());
  printf("sizeof(v2) = %zu\n", sizeof(v2));
}

