Point2和Point3类定义
支持以下图中的运算

类声明:
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类定义的更多相关文章
- Sampler类定义
此是所有采样的基类,这样定义的好处是,我们可以分别测试每一个采样算法. 类定义: #pragma once #ifndef __SAMPLER_HEADER__ #define __SAMPLER_H ...
- Sphere类定义
这个类是球体,也就是一会要显示的球体了.这个类继承于Geometrics类,并实现了自己的碰撞检测,碰撞原理,书上也说的很清楚了啊,大家多看.然后对照代码就明白了. 类定义: #pragma once ...
- Python笔记——类定义
Python笔记——类定义 一.类定义: class <类名>: <语句> 类实例化后,可以使用其属性,实际上,创建一个类之后,可以通过类名访问其属性 如果直接使用类名修改其属 ...
- 几种常用的JS类定义方法
几种常用的JS类定义方法 // 方法1 对象直接量var obj1 = { v1 : "", get_v1 : function() { return ...
- Js 类定义的几种方式
提起面向对象我们就能想到类,对象,封装,继承,多态.在<javaScript高级程序设计>(人民邮电出版社,曹力.张欣译.英文名字是:Professional JavaScript for ...
- 为什么C++类定义中,数据成员不能被指定为自身类型,但可以是指向自身类型的指针或引用?为什么在类体内可以定义将静态成员声明为其所属类的类型呢 ?
static的成员变量,不是存储在Bar实例之中的,因而不会有递归定义的问题. 类声明: class Screen: //Screen类的声明 1 类定义: class Screen{ //Scree ...
- C++学了这么多年,你也许不知道为什么类定义要放在.h文件,类实现放在cpp文件。它们如何关联?
原文 http://blog.csdn.net/ithzhang/article/details/8119286 主题 C++ C++学了这么多年你知道为什么定义类时,类的定义放在.h文件中,而类 ...
- YTU 2602: 熟悉题型——类设计( 矩形类定义【C++】)
2602: 熟悉题型--类设计( 矩形类定义[C++]) 时间限制: 1 Sec 内存限制: 128 MB 提交: 183 解决: 119 题目描述 定义一个矩形类,数据成员包括左下角和右上角坐标 ...
- Objective-c 类接口 (@interface) (类定义)
在Objective-c中如何定义一个类呢?我们可以使用下面的格式进行表示: @interface 类名:父类名{ 变量定义; } 方法定义: @end; 下面给出一个实例: @interface P ...
随机推荐
- linux篇-tomcat:Cannot find /usr/local/tomcat1/bin/setclasspath.sh
首先看下报错代码: Cannot find /usr/local/tomcat1/bin/setclasspath.sh This file is needed to run this program ...
- awd平台搭建及遇到的问题
1.安装docker环境 a.使用的是ubuntu系统,通过sudo apt install docker.io进行docker得安装,此方式会自动启动docker服务. b.通过curl -s ht ...
- React中使用react-player 播放视频或直播
业务中需要播放视频,寻来寻去,找到了react-player 初次点击,甚是眼熟,思来想去,竟是钉钉同款 如果使用react框架 先安装 npm install --save video-react ...
- Linux离线包管理器RPM
Linux离线包管理器RPM RPM 是RedHat Package Manager(RedHat软件包管理工具). 1.rpm常用参数介绍 查看rpm是否安装 rpm -q rpm包名 [root@ ...
- Camunda如何适配国产数据库达梦
前言 camunda流程引擎官方支持的数据库有:MySQL .MariaDB .Oracle .DB2 .PostgreSQL .SQL Server.H2.对于其他类型的数据库如何支持,尤其是国产数 ...
- Redis配置文件所在位置
更新记录 2022年6月13日 发布. Windows系统 Redis 配置文件位于 Redis 安装目录下文件名为 redis.conf 注意:Windows系统下名为 redis.windows. ...
- 拥抱 OpenAPI 3:springdoc-openapi 食用指南
概述 使用 springdoc-openapi 可以快速为 springboot 项目生成规范的 API 文档,具体使用步骤如下: 依赖配置 在 pom.xml 加入内容,即可开始使用: <de ...
- 【Java面试】请简单说一下你对受检异常和非受检异常的理解
Hi,我是Mic 今天给大家分享一道阿里一面的面试题. 这道题目比较基础,但是确难倒了很多人. 关于"受检异常和非受检异常的理解" 我们来看看普通人和高手的回答. 普通人: 嗯.. ...
- python+anaconda+pycharm的使用
研一开学的时候开始接触了这些,但是对于其各种功能感到十分混乱,现在通过这篇博文将其功能详细的写出来. 1.python解释器 首先要了解python解释器,我们俗称的下载python也就是下载pyth ...
- window下Redis快速启动,以及闪退问题解决
我下载的是免安装版的window版redis,解压后如下: 第一步:在解压的redis文件夹下新建一个redis-start.bat(window启动一般都是xx.bat) 第二步:打开redis.w ...