structpoint { int x, y; point() {} // default constructor point (int _x, int _y) { x = _x; y = _y; } };
也可以这样写:
1 2 3 4 5
structpoint { int x, y; point() {} // default constructor point (int x, int y): x(x), y(y) {} };
注* 括号里的是赋值的参数 好像容易记错。
小于号 <
1 2 3 4 5 6 7 8
structpoint { int x, y; // overloading of < operator booloperator<(const point &rhs) const{ // your main logic for the comparator goes here return make_pair(x,y) < make_pair(rhs.x, rhs.y); } };