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

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

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

問題描述

整個夏天我一直在使用Accelerated C++"來學習 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){}

相當于

cin >> x;
if (cin){}

通過查看代碼,在我看來,我們正在使用 cin 作為變量.但是,我認為這是一個函數(shù).當 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 表示標準輸入流.它對應于cstdiostdin.操作符 >>> 重載流返回對同一流的引用.流本身可以通過轉換運算符在布爾條件中評估為真或假.

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.

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

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

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

【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(liá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ù)學式鏈接-如“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 表達式中的變量聲明)
主站蜘蛛池模板: 秋霞一区二区 | 午夜激情福利视频 | 国产吃瓜黑料一区二区 | 精品一区二区三区在线观看 | 国产精品二区一区二区aⅴ污介绍 | 国产盗摄一区二区三区 | 亚洲精品福利视频 | 亚洲欧美中文字幕 | 91视频网页| 成人免费动漫 | 欧美在线播放视频 | 欧美精品在线观看视频 | 一级特黄毛片 | 国产精品久久久久久久久久久久午夜片 | 亚洲国产二区 | 亚洲精品一区二区三区在线观看 | 日日日干干干 | aaaaaa毛片| 国产精品手机在线 | 日韩精品免费视频 | 人与拘一级a毛片 | 黄色大片av | 91亚洲一区 | 黄色国产视频 | 官场少妇尤物雪白高耸 | 一级黄色av| 天天综合天天 | 亚洲精品一区中文字幕乱码 | 九九香蕉视频 | www.啪啪| 欧美黄色片视频 | 性欧美8khd高清极品 | 四虎影视最新地址 | 国产日韩精品一区二区 | 日韩精品久久久久久免费 | 久久国产一区二区三区 | 综合久久久久 | 欧美一级淫片免费视频黄 | 久久精品小视频 | 美女国产精品 | 韩国三级av |