720a.cpp

来自「C++实训教程」· C++ 代码 · 共 27 行

CPP
27
字号
//720a.cpp from 711.CPP demo iostream
//int x,y,z; from public to private:
#include <iostream.h>
class Point
{
	friend ostream& operator << (ostream& is,Point p);
	int x,y,z;	// 3_d coordinates
  public:
	Point(int a,int b,int c)
	{	x=a;		y=b;		z=c;	}
};
// Display X,Y,Z coordinates--Point insertor
ostream& operator << (ostream& is,Point p)
{
     is << p.x << " , ";
     is << p.y << " , ";
     is << p.z << "\n";
	return is;
}

main(void)
{
  Point d1(1,11,111), d2(2,22,222), d3(3,33,333);
  cout << d1<< d2 << d3  << endl ;
  return 0;
}

⌨️ 快捷键说明

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