template <class T> struct vector2 { T x, y; vector2(const T& x, const T& y) : x(x), y(y) {} }; template <class T> T inner_product(const vector2<T>& v, const vector2<T>& u) { return v.x * u.x + v.y * u.y; } #include <iostream> int main() { vector2<float> v(-1, 1); vector2<float> u(1, -2); std::cout << inner_product(v, u) << std::endl; }
-3