prog14.cpp

来自「C++语言程序设计题典」· C++ 代码 · 共 31 行

CPP
31
字号
#include <iostream.h>
class Point
{
	int x,y,z;
public:
	Point(int i,int j,int k)
	{
		x=i;y=j;z=k;
	}
	friend ostream& operator<<(ostream &,Point &);
	friend istream& operator>>(istream &,Point &);
};
ostream& operator<<(ostream &os,Point &p)
{
	cout << "坐标:(" << p.x << "," << p.y << "," << p.z << ")" << endl;
	return os;
}
istream& operator>>(istream &is,Point &p)
{
	is >> p.x >> p.y >> p.z;
	return is;
}
void main()
{
	Point p(1,2,3);
	cout << p;
	cout << "输入新坐标:";
	cin >> p;
	cout << p;
}

⌨️ 快捷键说明

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