您的位置:首页 > 编程语言 > C语言/C++

cpp 输出<< 重载

2012-04-27 22:54 92 查看
#include <iostream>

using namespace std;

struct vertex{
int x;
int y;
int z;
// Input and Output
friend std::ostream& operator<<(std::ostream& os, const vertex& vo);

};
std::ostream&operator<<(std::ostream& os, const vertex& vo)
{
return os << "<" << vo.x << ", " << vo.y << ", " << vo.z << ">";
}

void main()
{
vertex v;
v.x = 0;
v.y = 1;
v.z = 2;
cout<<v;
return;
}

//输出<0, 1, 2>Press any key to continue
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐