Problem p00081 (C++)

Buggy submission (status: Runtime Error):
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
using namespace std;
#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)
class Point {
public:
  long double x, y;
  Point(long double x = 0, long double y = 0) : x(x), y(y) {}
  Point operator+(Point p) { return Point(x + p.x, y + p.y); }
  Point operator-(Point p) { return Point(x - p.x, y - p.y); }
  Point operator*(double a) { return Point(x * a, y * a); }
  Point operator/(double a) { return Point(x / a, y / a); }
  long double abs() { return sqrt(norm()); }
  long double norm() { return x * x + y * y; }
  bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; }
  bool operator>(const Point &p) const { return x != p.x ? x > p.x : y > p.y; }
  bool operator==(const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};
struct Segment {
  Point p1, p2;
};
long double norm(Point p) { return p.x * p.x + p.y * p.y; }
long double abs(Point p) { return sqrt(norm(p)); }
double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
Point projection(Segment a, Point b) {
  Point sa = a.p2 - a.p1;
  double hyp = dot(b - a.p1, sa);
  double r = hyp / norm(sa);
  return a.p1 + sa * r;
}
Point reflection(Segment a, Point b) {
  return b + ((projection(a, b) - b) * 2.0);
}
int main() {
  Point P1, P2, P3;
  Segment G;
  int q;
  while (scanf("%Lf,%Lf,%Lf,%Lf,%Lf,%Lf", &P2.x, P2.y, P3.x, P3.y, P1.x,
               P1.y) != EOF) {
    G.p1 = P2;
    G.p2 = P3;
    P2 = reflection(G, P1);
    cout << fixed << setprecision(15) << P2.x << ' ' << fixed
         << setprecision(15) << P2.y << endl;
  }
  return 0;
}

Fixed submission:
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
using namespace std;
#define EPS 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPS)
class Point {
public:
  long double x, y;
  Point(long double x = 0, long double y = 0) : x(x), y(y) {}
  Point operator+(Point p) { return Point(x + p.x, y + p.y); }
  Point operator-(Point p) { return Point(x - p.x, y - p.y); }
  Point operator*(double a) { return Point(x * a, y * a); }
  Point operator/(double a) { return Point(x / a, y / a); }
  long double abs() { return sqrt(norm()); }
  long double norm() { return x * x + y * y; }
  bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; }
  bool operator>(const Point &p) const { return x != p.x ? x > p.x : y > p.y; }
  bool operator==(const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};
struct Segment {
  Point p1, p2;
};
long double norm(Point p) { return p.x * p.x + p.y * p.y; }
long double abs(Point p) { return sqrt(norm(p)); }
double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
Point projection(Segment a, Point b) {
  Point sa = a.p2 - a.p1;
  double hyp = dot(b - a.p1, sa);
  double r = hyp / norm(sa);
  return a.p1 + sa * r;
}
Point reflection(Segment a, Point b) {
  return b + ((projection(a, b) - b) * 2.0);
}
int main() {
  Point P1, P2, P3;
  Segment G;
  int q;
  while (scanf("%Lf,%Lf,%Lf,%Lf,%Lf,%Lf", &P2.x, &P2.y, &P3.x, &P3.y, &P1.x,
               &P1.y) != EOF) {
    G.p1 = P2;
    G.p2 = P3;
    P2 = reflection(G, P1);
    cout << fixed << setprecision(15) << P2.x << ' ' << fixed
         << setprecision(15) << P2.y << endl;
  }
  return 0;
}