作者在 2014-04-27 09:21:28 发布以下内容
#include <iostream>
using namespace std;
class point
{
private:
double fx,fy;
public:
point();//不带参
point(double fx,double fy);//带参
void showpoint();
};
point::point()
{
fx=0.0;
fy=0.0;
}
point::point(double x,double y=5.0)
{
fx=x;
fy=y;
}
void point::showpoint()
{
cout<<fx<<" "<<fy<<endl;
}
void main()
{
point f1;
cout<<"the fx and fy of f1: ";
f1.showpoint();
point f2(10);
cout<<"the fx and fy of f2: ";
f2.showpoint();
point f3(1.1,2.0);
cout<<"the fx and fy of f3: ";
f3.showpoint();
}