C++ 平面点类,记得调用函数后面要加()

#include <iostream>
using namespace std;
class point
{
private :
	double  x, y;
public :
	void input()
	{
		cin >> x;
		cin >> y;
	}
	double distence()
	{
		double c = sqrt(x*x + y * y);
		return c;
	}
	void output()
	{
		cout << "(" << x << "," << y << ")" << endl;
	}
};
int main()
{
	point aa;
	point bb;
	aa.input();
	bb.input();
	double c = aa.distence();
	double d = bb.distence();
	if (c > d)
	{
		bb.output();//记得函数后面要加()
	}
	else
		aa.output();
	system("pause");
	return 0;
}

 

猜你喜欢

转载自blog.csdn.net/qq_43312665/article/details/88039130