test7.2_3dpointtest.cpp

来自「定义并实现复数类」· C++ 代码 · 共 61 行

CPP
61
字号
/*#include<iostream>
using namespace std;
class point
{
	double  x,y,z;
public:
	point()
	{
		x=y=z=0;
	}
	point(double x,double y,double z)
	{
		this->x=x;
		this->y=y;
		this->z=z;
	}
	point operator+(point &p)
	{
		point temp(x+p.x,y+p.y,z+p.z);
		return temp;
	}
	point operator-(point &p)
	{
		point temp(x-p.x,y-p.y,z-p.z);
		return temp;
	}
	point operator=(point &p)
	{
		point temp((x=p.x),(y=p.y),(z=p.z));
		return temp;
	}
	static void show(point &p)
	{
		cout<<"("<<p.x<<","<<p.y<<","<<p.z<<")"<<endl;
	}

};
void main()
{
	point p1(1.1,2.2,3.3),p2(4.4,5.5,6.6),total,difference,evaluate;
	total=p1+p2;
	cout<<"点p1   ";
	point::show(p1);
	cout<<"与点p2 ";
	point::show(p2);
	cout<<"之和是:";
	point::show(total);
	difference=p1-p2;
	cout<<"点p1   ";
	point::show(p1);
	cout<<"与点p2 ";
	point::show(p2);
	cout<<"之差是:";
	point::show(difference);
	evaluate=p1;
	cout<<"点p1   ";
	point::show(p1);
	cout<<"赋值给点evaluate(0,0,0)结果是: ";
	point::show(evaluate);

}*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?