int main() { std::vector<Point> points; points.push_back(Point(1, 1)); points.push_back(Point(2, 1)); points.push_back(Point(1, 3)); /* MyFun f(Point(0, 0)); f( Point(0, 0), Point(0, 0) ); */ std::sort(points.begin(), points.end(), MyFun(Point(1, 4)) ); std::copy(points.begin(), points.end(), std::ostream_iterator<Point>(std::cout, "\n") ); return 0; }
int main(int argc, char* argv[]) { MyFun(10); /* 这是直接调用MyFun函数 */ FunP = &MyFun; /* 将MyFun函数的地址赋给FunP变量 */ (*FunP)(20); /* (★)这是通过函数指针变量FunP来调用MyFun函数的。 */ }