Copyright (c) 2016,烟台大学计算机学院.
All rights reserced.
文件名称:test.cpp
作者 :秦通
完成日期:2016.6.02
版本号 :Codeblocks
问题描述:建立一个Point类,包含数据成员x,y(坐标点),实现需要的成员函数。
程序输入:
#include"iostream"
using namespace std;
class Point
{
public:
Point(double x1,double y1):x(x1),y(y1){}
void show();
private:
double x;
double y;
};
void Point::show()
{
cout<<x<<" "<<y<<endl;
}
int main()
{
Point a(4.0,3.0);
Point b(3.0,5.0);
a.show();
b.show();
return 0;
}
运行结果: