C++面向对象程序设计 030:你真的搞清楚为啥 while(cin >> n) 能成立了吗? ---- (北大Mooc)
发布日期:2021-06-30 22:27:46 浏览次数:2 分类:技术文章

本文共 429 字,大约阅读时间需要 1 分钟。

文章目录


专题博客链接


原题题目

在这里插入图片描述

#include 
using namespace std;class MyCin{
// 在此处补充你的代码};int main(){
MyCin m; int n1,n2; while( m >> n1 >> n2) cout << n1 << " " << n2 << endl; return 0;}

代码实现

private:    int judge;public:    MyCin():judge(1){
} MyCin& operator >>(int& n) {
cin>>n; if(n == -1) judge = 0; return *this; } operator int(){
return judge;}};

转载地址:https://love6.blog.csdn.net/article/details/114997433 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Python课后作业 1. 输入三个字符从小到大排序(第三次作业)
下一篇:C++面向对象程序设计 029:简单的Filter ---- (北大Mooc)

发表评论

最新留言

做的很好,不错不错
[***.243.131.199]2024年04月28日 18时33分14秒