支持以下图中的运算

类声明:

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. redis高可用、redis集群、redis缓存优化

    今日内容概要 redis高可用 redis集群 redis缓存优化 内容详细 1.redis高可用 # 主从复制存在的问题: 1 主从复制,主节点发生故障,需要做故障转移,可以手动转移:让其中一个sl ...

  2. Spring Authorization Server 0.3.0 发布,官方文档正式上线

    基于OAuth2.1的授权服务器Spring Authorization Server 0.3.0今天正式发布,在本次更新中有几大亮点. 文档正式上线 Spring Authorization Ser ...

  3. .net6.0 初探

    概述:大概的了解一下 dotnet 6.0 建立 MVC web项目的过程以及程序调用  结合 EF 框架进行简单 的CRUD 1.选择创建  MVC 的Web项目 2.框架类型选择 6.0 3. 6 ...

  4. 【ACM程序设计】动态规划 第二篇 LCS&LIS问题

    动态规划 P1439 [模板]最长公共子序列 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 题目描述 给出 1,2,-,n 的两个排列 P1 和 P2 ,求它们的最长公共子序列. ...

  5. Java集合框架(一)-ArrayList

    大佬理解->Java集合之ArrayList 1.ArrayList的特点 存放的元素有序 元素不唯一(可以重复) 随机访问快 插入删除元素慢 非线程安全 2.底层实现 底层初始化,使用一个Ob ...

  6. WinSCP和PuTTY的安装和使用

    简介 WinSCP是一个Windows环境下使用SSH的开源图形化SFTP客户端.同时支持SCP协议.它的主要功能就是在本地与远程计算机间安全的复制文件. 安装 1.下载地址:https://www. ...

  7. Android 12(S) 图像显示系统 - HWC HAL 初始化与调用流程

    必读: Android 12(S) 图像显示系统 - 开篇 接口定义 源码位置:/hardware/interfaces/graphics/composer/ 在源码目录下可以看到4个版本的HIDL ...

  8. EasyExcel导出创建Excel下拉框

    话不多说,上才艺. 下面代码粘贴即用 /** * * 导出表格带下拉框 */ @GetMapping("exportBox") public void export(HttpSer ...

  9. Set集合转换为List集合

    举个栗子,看图:

  10. 👨‍💻Mybatis源码我搞透了,面试来问吧!写了134个源码类,1.03万行代码!

    作者:小傅哥 博客:https://bugstack.cn 沉淀.分享.成长,让自己和他人都能有所收获! 一.前言:手撸一万行! 完结撒花:4个月.20章.134个类.1.03万行代码! 22年3月初 ...