《C++捷径教程》读书笔记--Chapter 18--C++的I/O系统--2

来源:互联网 发布:kudo apache 编辑:程序博客网 时间:2024/05/08 02:03

//--《C++捷径教程》读书笔记--Chapter 18--C++的I/O系统
//--Chapter 18--C++的I/O系统
//--10/15/2006 Sun.
//--Computer Lab
//--Liwei

//说明插入符的用法,使用友员
#include <iostream>
using namespace std;

class three_d{
 int x,y,z;
public:
 three_d(int a, int b, int c){ x=a; y=b; z=c; }
 friend ostream &operator<<( ostream &stream, three_d obj);
};

ostream &operator<<( ostream &stream, three_d obj )
{
 stream << obj.x << ",";
 stream << obj.y << ",";
 stream << obj.z << "/n";
 return stream;
}

int main()
{
 three_d a(1,2,3), b(4,5,6), c(7,8,9);
 
 co << a << b << c;

 return 0; 

原创粉丝点击