/*
All rights reserced.
文件名称:main.cpp
作者:李鑫
完成日期:2016.5.24
问题描述 :自我设计Point点类。
*/
#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(3.0,5.0);
Point b(4.0,3.0);
a.show();
b.show();
return 0;
}
运行结果:
学习心得:发现自己关于 Point(double x1,double y1):x(x1),y(y1){}这样的构造函数很容易写错