#include<iostream>
using namespace std;
class point
{
private:
float fx,fy;
public:
point(float x,float y);
void showpoint();
};
point::point(float x,float y)
{
fx=x;
fy=y;
}
void point::showpoint()
{
cout<<"fx="<<fx<<" fy="<<fy<<endl;
}
void main()
{
point p1(1.1,2.2);//使用构造函数创建对象p1
p1.showpoint();
point p2(p1);//使用默认拷贝构造函数创建对象p2
p2.showpoint();
}
默认复制(拷贝)构造函数
最新推荐文章于 2024-04-16 21:15:13 发布