Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d595123b02e488a88f77e826e03fa5cc5055673b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * Indentation
 */
#include <math.h>
class Point {
public:
	Point(double xc, double yc) :
		x(xc), y(yc) {
	}
	double distance(const Point& other) const;
	int compareX(const Point& other) const;
	double x;
	double y;
};
double Point::distance(const Point& other) const {
	double dx = x - other.x;
	double dy = y - other.y;
	return sqrt(dx * dx + dy * dy);
}
int Point::compareX(const Point& other) const {
	if (x < other.x) {
		return -1;
	} else if (x > other.x) {
		return 1;
	} else {
		return 0;
	}
}
namespace FOO {
int foo(int bar) const {
	switch (bar) {
	case 0:
		++bar;
		break;
	case 1:
		--bar;
	default: {
		bar += bar;
		break;
	}
	}
}
} // end namespace FOO

Back to the top