#include using namespace std; template struct Point { T x, y; Point(T x = 0, T y = 0) : x(x), y(y) {} }; template Point operator+(const Point &A, const Point &B) { return Point(A.x + B.x, A.y + B.y); } template ostream &operator<<(ostream &out, const Point &p) { out << "(" << p.x << "," << p.y << ")"; return out; } template T sum(T *begin, T *end) { T ans = 0; for (T *p = begin; p != end; p++) { ans = ans + *p; } return ans; } int main() { Point c(1.1, 2.2), d(3.3, 4.4); cout << c + d << endl; Point b[] = {Point(1, 2), Point(3, 4), Point(5, 6), Point(7, 8)}; cout << sum(b, b + 4) << endl; return 0; }