支持以下图中的运算

类声明:

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. MyBatis热部署

    代码 import java.io.IOException; import java.lang.reflect.Field; import java.util.HashMap; import java ...

  2. Nexus5x 修改Android开机动画

    1.制作帧动画 这里随便从网上找了一个gif图片,导入PS中,打开后会形成很多帧图层,选择导航栏中的文件->脚本->将图层导出到文件可以将所有图层导出来.要注意文件命名,Android会按 ...

  3. 【js奇妙说】如何跟非计算机从业者解释,为什么浮点数计算0.1+0.2不等于0.3?

    壹 ❀ 引 0.1+0.2不等于0.3,即便你不知道原理,但也应该听闻过这个问题,包括博主本人也曾在面试中被问到过此问题.很遗憾,当时只知道一句精度丢失,但是什么原因造成的精度丢失却不太清楚.而我在查 ...

  4. STM32启动文件

    一.复位电路 在了解启动文件之前需要明白STM32的复位中断流程,STM32的复位分为上电复位和手动复位,复位的电路图如下所示: 注意: 图中的复位电路是低电平复位,有的MCU是高电平复位. 上电复位 ...

  5. docker的数据存储

    概述 Docker 为容器提供了两种存放数据的资源:由 storage driver 管理的镜像层和容器层:以及Data Volume. store driver Docker镜像的分层结构如下图所示 ...

  6. 【SpringSecurity系列1】基于SpringSecurity实现前后端分离无状态Rest API的权限控制

    源码传送门: https://github.com/ningzuoxin/zxning-springsecurity-demos/tree/master/01-springsecurity-state ...

  7. 【FAQ】运动健康服务REST API接口使用过程中常见问题和解决方法总结

    华为运动健康服务(HUAWEI Health Kit)为三方生态应用提供了REST API接口,通过其接口可访问数据库,为用户提供运动健康类数据服务.在实际的集成过程中,开发者们可能会遇到各种问题,这 ...

  8. Lucene从入门到实战

    Lucene 在了解Lucene之前,我们先了解下全文数据查询. 全文数据查询 我们的数据一般分为两种:结构化数据和非结构化数据 结构化数据:有固定格式或有限长度的数据,如数据库中的数据.元数据 非结 ...

  9. 拙见--springMVC的controller接受的请求参数

    1-这种是最常用的表单参数提交,ContentType指定为application/x-www-form-urlencoded,也就是会进行URL编码. 1.1-对象类型实体Bean接收请求参数(表单 ...

  10. Xilinx DMA的几种方式与架构

    DMA是direct memory access,在FPGA系统中,常用的几种DMA需求: 1. 在PL内部无PS(CPU这里统一称为PS)持续干预搬移数据,常见的接口形态为AXIS与AXI,AXI与 ...