问题及代码:
/*
*Copyright (c) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称 :
*作 者 : 王艺霖
*完成日期 : 2016年5月9号
*版 本 号 : v6.0
*问题描述 : 点、圆、圆柱类的设计,先建立一个Point(点)类,包含数据成员x,y(坐标点),实现需要的成员函数,并设计main函数完成测试;
*输入描述 : 无
*程序输出 :
*/
#include <iostream>
using namespace std;
class Point
{
public:
Point(double x=0,double y=0);
void show();
protected:
double x,y;
};
Point::Point(double a,double b)
{
x=a;
y=b;
}
void Point::show()
{
cout<<"("<<x<<","<<y<<")"<<endl;
}
int main()
{
Point point(1.2,1.3);
point.show();
return 0;
}
运行结果: