问题及代码:
/*Copyright (c)2016,烟台大学计算机与控制工程学院
*All rights reserved.
*文件名称:main.cpp
*作 者:贾庆严
*完成日期:2016年5月11日
*版 本 号:v1.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.3,1.4);
point.show();
return 0;
}
运算结果: