/*copyright(c)2016.烟台大学计算机学院
* All rights reserved,
* 文件名称:text.Cpp
* 作者:刘涛
* 完成日期:2016年5月7日
* 版本号:vc++6.0
* 问题描述:建立一个点类
*/
#include<iostream>
using namespace std;
#define Pi 3.1415926
class Point
{
private:
double x,y;
public:
Point(double x1,double y1):x(x1),y(y1){}
double getX()
{
return x;
}
double getY()
{
return y;
}
void print()
{
cout<<"横坐标:"<<x<<" "<<"纵坐标:"<<y<<endl;
}
};
int main()
{
Point p(2.1,3.2);
p.print();
return 0;
}
运行结果:<img src="https://img-blog.csdn.net/20160507145040552?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />