首页 > 编程语言 > 详细

C++重载输入流复习

时间:2018-03-09 23:54:13      阅读:303      评论:0      收藏:0      [点我收藏+]

C++重载输入流

#include <bits/stdc++.h>

using namespace std;

struct Point {
    int x, y;
    Point(int xx, int yy):x(xx), y(yy) {}
    Point():x(0), y(0) {}
    friend ostream& operator << (ostream &os, const Point & p) {
        os << "[" << p.x << " " << p.y << "]";
    }
    friend istream& operator >> (istream &is,Point &p) {
        is >> p.x >> p.y;
    }
} a;

int main()
{
    cin >> a;
    cout << a << endl;
    return 0;
}

C++重载输入流复习

原文:https://www.cnblogs.com/Q1143316492/p/8536812.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!