支持以下图中的运算

类声明:

class Point2 {
public:
Point2();
~Point2();
Point2(ldouble a);
Point2(ldouble a, ldouble b);
Point2(const Point2& p);
Point2 operator+(const Point2& p) const;
Point2& operator+=(const Point2& p);
Point2 operator-(const Point2& p) const;
Point2& operator-=(const Point2& p);
Point2 operator*(ldouble a) const;
Point2& operator*=(ldouble a);
Point2 operator/(ldouble f) const;
Point2& operator/=(ldouble f);
Point2 operator-() const;
Point2& operator=(const Point2& p);
bool operator==(const Point2& p) const;
bool operator!=(const Point2& p) const;
friend ldouble distance(const Point2& p1, const Point2& p2);
friend ldouble distance_squared(const Point2& p1, const Point2& p2);
friend Point2 operator*(ldouble a, const Point2& p);
friend std::ostream& operator<<(std::ostream& os, const Point2& p);
friend std::istream& operator>>(std::istream& is, Point2& p);
ldouble x, y;
}; class Point3 {
public:
Point3();
~Point3();
Point3(ldouble a);
Point3(ldouble a, ldouble b, ldouble c);
Point3(const Point2& p);
Point3(const Point3& p);
Point3 operator+(const Vector3& v) const;
Point3& operator+=(const Vector3& v);
Vector3 operator-(const Point3& p) const;
Point3 operator-(const Vector3& v) const;
Point3& operator-=(const Vector3& v);
Point3 operator*(ldouble a) const;
Point3& operator*=(ldouble a);
Point3 operator/(ldouble f) const;
Point3& operator/=(ldouble f);
Point3 operator-() const;
Point3& operator=(const Point3& p);
bool operator==(const Point3& p) const;
bool operator!=(const Point3& p) const;
friend ldouble distance(const Point3& p1, const Point3& p2);
friend ldouble distance_squared(const Point3& p1, const Point3& p2);
friend Point3 operator*(ldouble a, const Point3& p);
friend std::ostream& operator<<(std::ostream& os, const Point3& p);
friend std::istream& operator>>(std::istream& is, Point3& p);
ldouble x, y, z;
};

  

实现还是作为练习,图中已经写明了运算了。

Point2和Point3类定义的更多相关文章

  1. Sampler类定义

    此是所有采样的基类,这样定义的好处是,我们可以分别测试每一个采样算法. 类定义: #pragma once #ifndef __SAMPLER_HEADER__ #define __SAMPLER_H ...

  2. Sphere类定义

    这个类是球体,也就是一会要显示的球体了.这个类继承于Geometrics类,并实现了自己的碰撞检测,碰撞原理,书上也说的很清楚了啊,大家多看.然后对照代码就明白了. 类定义: #pragma once ...

  3. Python笔记——类定义

    Python笔记——类定义 一.类定义: class <类名>: <语句> 类实例化后,可以使用其属性,实际上,创建一个类之后,可以通过类名访问其属性 如果直接使用类名修改其属 ...

  4. 几种常用的JS类定义方法

    几种常用的JS类定义方法   // 方法1 对象直接量var obj1 = {    v1 : "",    get_v1 : function() {        return ...

  5. Js 类定义的几种方式

    提起面向对象我们就能想到类,对象,封装,继承,多态.在<javaScript高级程序设计>(人民邮电出版社,曹力.张欣译.英文名字是:Professional JavaScript for ...

  6. 为什么C++类定义中,数据成员不能被指定为自身类型,但可以是指向自身类型的指针或引用?为什么在类体内可以定义将静态成员声明为其所属类的类型呢 ?

    static的成员变量,不是存储在Bar实例之中的,因而不会有递归定义的问题. 类声明: class Screen: //Screen类的声明 1 类定义: class Screen{ //Scree ...

  7. C++学了这么多年,你也许不知道为什么类定义要放在.h文件,类实现放在cpp文件。它们如何关联?

    原文  http://blog.csdn.net/ithzhang/article/details/8119286 主题 C++  C++学了这么多年你知道为什么定义类时,类的定义放在.h文件中,而类 ...

  8. YTU 2602: 熟悉题型——类设计( 矩形类定义【C++】)

    2602: 熟悉题型--类设计( 矩形类定义[C++]) 时间限制: 1 Sec  内存限制: 128 MB 提交: 183  解决: 119 题目描述 定义一个矩形类,数据成员包括左下角和右上角坐标 ...

  9. Objective-c 类接口 (@interface) (类定义)

    在Objective-c中如何定义一个类呢?我们可以使用下面的格式进行表示: @interface 类名:父类名{ 变量定义; } 方法定义: @end; 下面给出一个实例: @interface P ...

随机推荐

  1. cpulimit-限制CPU速率

    CPULimit是一个简单的程序,它可以限制指定进程的CPU百分比. 1.安装依赖 root@localhost:~# apt-get -y install git 2.从GitHUB中克隆源码到本地 ...

  2. 1.3温度转换(中国大学Mooc-Python 语言程序设计)

    温度转换 温度刻画的两种不同体系 1.摄氏度:(中国等世界大多数国家使用) 以1标准大气压下水的结冰点为0度,沸点为100度,将温度进行等分刻画  2.华氏度:(美国.英国等国家使用) 以1标准大气压 ...

  3. 2021.06.05【NOIP提高B组】模拟 总结

    T1 题意:给你一个 \(n\) 个点 \(n\) 条边的有向图, 求每个店经过 \(K\) 条边后的边权和.最小边权 \(K\le 10^{10}\) 考试时:一直想着环,结果一直不知道怎么做 正解 ...

  4. 10分钟快速部署camunda BPM开源版

    安装部署Camunda BPM有多种方式,基于Camunda独立web应用程序安装部署是最简单的一种方式,您只需要有tomcat即可. 本文档将指导您安装和配置Camunda独立web应用程序,快速体 ...

  5. 基于SqlSugar的开发框架循序渐进介绍(8)-- 在基类函数封装实现用户操作日志记录

    在我们对数据进行重要修改调整的时候,往往需要跟踪记录好用户操作日志.一般来说,如对重要表记录的插入.修改.删除都需要记录下来,由于用户操作日志会带来一定的额外消耗,因此我们通过配置的方式来决定记录那些 ...

  6. 一些好用的javascript/typescript方法封装分享

    1.数字格式化 JS版-直接写到原型链上 /** * @author: silencetea * @name: * @description: 数字格式化,默认每三位用英文逗号分隔 * @param ...

  7. Redis之时间轮机制(五)

    一.什么是时间轮 时间轮这个技术其实出来很久了,在kafka.zookeeper等技术中都有时间轮使用的方式. 时间轮是一种高效利用线程资源进行批量化调度的一种调度模型.把大批量的调度任务全部绑定到同 ...

  8. 十分钟快速实战Three.js

    前言 本文不会对Three.js几何体.材质.相机.模型.光源等概念详细讲解,会首先分成几个模块给大家快速演示一盒小案例.大家可以根据这几个模块快速了解Three.js的无限魅力.学习 我们会使用Th ...

  9. 【WPF】CAD工程图纸转WPF可直接使用的xaml代码技巧

    前言:随着工业化的进一步发展,制造业.工业自动化等多领域,都可能用到上位监控系统.而WPF在上位监控系统方面,应该算是当下最流行的前端框架之一了.而随着监控体系的不断完善与更新迭代,监控画面会变得越来 ...

  10. 解决远程连接阿里云服务器的Redis失败问题

    参考网址: https://www.pianshen.com/article/91461328818/ https://blog.csdn.net/weixin_42518709/article/de ...