码迷,mamicode.com
首页 > 编程语言 > 详细

C++重载输入流复习

时间:2018-03-10 00:09:44      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:blog   cout   struct   log   space   int   return   cpp   mes   

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++重载输入流复习

标签:blog   cout   struct   log   space   int   return   cpp   mes   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!