Description

在数学上,平面直角坐标系上的点用X轴和Y轴上的两个坐标值唯一确定。现在我们封装一个“Point类”来实现平面上的点的操作。

根据“append.cc”,完成Point类的构造方法和show()方法,输出各Point对象的构造和析构次序。

接口描述:
Point::show()方法:按输出格式输出Point对象。

Input

输入多行,每行为一组坐标“x,y”,表示点的x坐标和y坐标,x和y的值都在double数据范围内。

Output

输出每个Point对象的构造和析构行为。对每个Point对象,调用show()方法输出其值:X坐标在前,Y坐标在后,Y坐标前面多输出一个空格。每个坐标的输出精度为最长16位。输出格式见sample。

C语言的输入输出被禁用。

Sample Input

1,2
3,3
2,1

Sample Output

Point : (0, 0) is created.
Point : (1, 2) is created.
Point : (1, 2) Point : (1, 2) is erased.
Point : (3, 3) is created.
Point : (3, 3)
Point : (3, 3) is erased.
Point : (2, 1) is created.
Point : (2, 1)
Point : (2, 1) is erased.
Point : (0, 0) is copied.
Point : (1, 1) is created.
Point : (0, 0) Point : (1, 1)
Point : (0, 0) Point : (1, 1) is erased.
Point : (0, 0) is erased.
Point : (0, 0) is erased.

HINT

思考构造函数、拷贝构造函数、析构函数的调用时机。

Append Code

#include<iostream>
#include<iomanip>
using namespace std;
class Point
{
private:
    double x,y;
public:
    Point(){x=0,y=0;cout<<setprecision(16)<<"Point : (0, 0) is created.\n";}
    Point(double a,double b){x=a,y=b;cout<<setprecision(16)<<"Point : ("<<x<<", "<<y<<") is created.\n";}
    void show(){cout<<setprecision(16)<<"Point : ("<<x<<", "<<y<<")\n";}
    ~Point(){cout<<setprecision(16)<<"Point : ("<<x<<", "<<y<<") is erased.\n";}
    Point(Point &a){x=0,y=0;cout<<setprecision(16)<<"Point : (0, 0) is copied.\n";}
    Point(int a){x=a,y=a;cout<<setprecision(16)<<"Point : ("<<x<<", "<<y<<") is created.\n";}
};
int main()
{
    char c;
    double a, b;
    Point q;
    while(std::cin>>a>>c>>b)
    {
        Point p(a, b);
        p.show();
    }
    Point q1(q), q2(1);
    q1.show();
    q2.show();
    q.show();
}

转载于:https://www.cnblogs.com/TogetherLaugh/p/6544632.html

Problem E: 平面上的点——Point类 (II)相关推荐

  1. Problem D: 平面上的点——Point类 (IV)

    Problem D: 平面上的点--Point类 (IV) Time Limit: 1 Sec   Memory Limit: 4 MB Submit: 5400   Solved: 3167 [ S ...

  2. Problem F: 平面上的点——Point类 (VI)

    Problem F: 平面上的点--Point类 (VI) Time Limit: 1 Sec   Memory Limit: 4 MB Submit: 6636   Solved: 3048 [ S ...

  3. Problem A: 平面上的点——Point类 (I)

    Description 在数学上,平面直角坐标系上的点用X轴和Y轴上的两个坐标值唯一确定.现在我们封装一个"Point类"来实现平面上的点的操作. 根据"append.c ...

  4. 平面上的点——Point类 (II)

    Description 在数学上,平面直角坐标系上的点用X轴和Y轴上的两个坐标值唯一确定.现在我们封装一个"Point类"来实现平面上的点的操作. 根据"append.c ...

  5. 平面上的点——Point类

    Problem A: 平面上的点--Point类 (I) Time Limit: 1 Sec  Memory Limit: 4 MB Submit: 11586  Solved: 5189 [Subm ...

  6. 平面上的点——Point类 (VI)

    Problem D: 平面上的点--Point类 (VI)Time Limit: 1 Sec Memory Limit: 4 MB Submit: 7868 Solved: 3620 [Submit] ...

  7. 平面上的点——Point类 (I)

    Description 在数学上,平面直角坐标系上的点用X轴和Y轴上的两个坐标值唯一确定.现在我们封装一个"Point类"来实现平面上的点的操作. 根据"append.c ...

  8. Problem B: 立体空间中的点(II)

    Problem B: 立体空间中的点(II) Time Limit: 1 Sec   Memory Limit: 128 MB Submit: 1662   Solved: 1299 [ Submit ...

  9. java定义一个点_JAVA 定义一个Point类 它的对象是指一个平面上的点(x,y),在定义Point类中要定义它的三个构造函数...

    JAVA 定义一个Point类 它的对象是指一个平面上的点(x,y),在定义Point类中要定义它的三个构造函数 JAVA 定义一个Point类 它的对象是指一个平面上的点(x,y),在定义Point ...

最新文章

  1. subList用法详解
  2. 彻底删除SharePoint 2010 Content Database
  3. spring注解开发:容器中注册组件方式
  4. 为游戏开发者总结的20个 Unity 建议和技巧
  5. HashMap源码解读
  6. 如何使用 C# 中的 ValueTuple
  7. 构建maven项目插件_如何构建一个Maven插件
  8. 获取php服务器ip地址,PHP获取客户端和服务器IP地址
  9. 同步请求和异步请求的区别
  10. docker 容器数据卷
  11. python发送邮件有逗号_Python发送邮件
  12. bs和php,BSPHP - WEB源码|源代码 - 源码中国
  13. [2018.10.18 T1] 艾奇摘苹果
  14. Javascript高级程序设计第四版详细测评
  15. 什么是网络安全网格?
  16. 硬件笔记-贴片元器件焊接
  17. 《程序员健康指南》读书笔记
  18. Grafana 任意文件读取漏洞复现
  19. Mendix低代码开发
  20. 交叉编译工具的使用说明

热门文章

  1. [转]hadoop新手错误解决方法
  2. 排列、组合问题(递归)
  3. LIS(Longest Increasing Subsequence)最长上升(不下降)子序列
  4. 球球大作战测试服android版,球球大作战10.0体验服
  5. 状态栏编程(显示系统时间和进度条)
  6. java数组使用实验报告_JAVA数组与类的定义-java实验报告
  7. 前端:屏蔽F12审查元素,禁止修改页面代码
  8. 比较一下商业产品经理和用户产品经理?
  9. 产品经理思维模型:产品生命周期
  10. epic转移游戏_Epic游戏商城更改退款政策 和steam一模一样