久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

if (cin >> x) - 為什么你可以使用那個條件?

if (cin gt;gt; x) - Why can you use that condition?(if (cin x) - 為什么你可以使用那個條件?)
本文介紹了if (cin >> x) - 為什么你可以使用那個條件?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

整個夏天我一直在使用Accelerated C++"來學(xué)習(xí) C++,但有一個我似乎不太理解的概念.

I have been using "Accelerated C++" to learn C++ over the summer, and there's a concept which I don't seem to understand properly.

為什么

int x;
if (cin >> x){}

相當(dāng)于

cin >> x;
if (cin){}

通過查看代碼,在我看來,我們正在使用 cin 作為變量.但是,我認(rèn)為這是一個函數(shù).當(dāng) x 具有我們在鍵盤中輸入的任何值時,為什么我們可以這樣使用 cin?

By looking at the code, it seems to me that we're using cin as a variable. But, I thought it was a function. Why can we use cin in this way when it is x that has whatever value we input into our keyboard?

推薦答案

cinistream 表示標(biāo)準(zhǔn)輸入流.它對應(yīng)于cstdiostdin.操作符 >>> 重載流返回對同一流的引用.流本身可以通過轉(zhuǎn)換運算符在布爾條件中評估為真或假.

cin is an object of class istream that represents the standard input stream. It corresponds to the cstdio stream stdin. The operator >>overload for streams return a reference to the same stream. The stream itself can be evaluated in a boolean condition to true or false through a conversion operator.

cin 提供格式化的流提取.操作cin>>x;

cin provides formatted stream extraction. The operation cin >> x;

如果一個非數(shù)字值是一個整數(shù),那么x"是一個整數(shù)將會失敗進入.所以:

where "x" is an int will fail if a non-numeric value is entered. So:

if(cin>>x)

如果您輸入的是字母而不是數(shù)字,將返回 false.

will return false if you enter a letter rather than a digit.

這個關(guān)于使用 C++ I/O 的技巧和竅門 的網(wǎng)站也會對您有所幫助.

This website on tips and tricks using C++ I/O will help you too.

這篇關(guān)于if (cin >> x) - 為什么你可以使用那個條件?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

What do compilers do with compile-time branching?(編譯器如何處理編譯時分支?)
Can I use if (pointer) instead of if (pointer != NULL)?(我可以使用 if (pointer) 而不是 if (pointer != NULL) 嗎?)
Checking for NULL pointer in C/C++(在 C/C++ 中檢查空指針)
Math-like chaining of the comparison operator - as in, quot;if ( (5lt;jlt;=1) )quot;(比較運算符的數(shù)學(xué)式鏈接-如“if((5<j<=1)))
Difference between quot;if constexpr()quot; Vs quot;if()quot;(“if constexpr()之間的區(qū)別與“if())
C++, variable declaration in #39;if#39; expression(C++,if 表達式中的變量聲明)
主站蜘蛛池模板: 欧美一级久久 | www日日日 | 午夜影院在线观看 | 亚洲网站在线观看 | 国产高清在线精品 | 自拍偷拍第一页 | 一区二区三区视频在线免费观看 | 国产精品毛片无码 | 99成人精品 | 国产一区二区三区四区 | 国产精品一区二区三区在线 | 精品一区二区三区电影 | 午夜影视大全 | 国产精品欧美一区二区三区 | 在线观看中文字幕av | 久久久性色精品国产免费观看 | 欧美一区在线看 | 91精品国产乱码久久久久久久久 | 国产精品国产成人国产三级 | 成人h视频在线观看 | 中文字幕国产高清 | 日韩欧美一区二区三区免费观看 | 欧美精品一二三 | 91成人免费电影 | 成人乱人乱一区二区三区软件 | 国产精品视频一 | 久久r精品| 日韩在线看片 | 中文字幕 在线观看 | 91精品国产91 | 国产一区二区精品 | 中文字幕韩在线第一页 | a国产视频 | 欧美日韩综合视频 | 欧美三级在线 | www国产成人免费观看视频,深夜成人网 | 久久久91精品国产一区二区三区 | 国产成人久久 | 午夜激情视频 | 午夜欧美 | 午夜理伦三级理论三级在线观看 |