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

cout<<調用它打印的函數的順序?

cout lt;lt; order of call to functions it prints?(coutlt;lt;調用它打印的函數的順序?)
本文介紹了cout<<調用它打印的函數的順序?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

以下代碼:

myQueue.enqueue('a');
myQueue.enqueue('b');
cout << myQueue.dequeue() << myQueue.dequeue();

在控制臺打印ba"

同時:

myQueue.enqueue('a');
myQueue.enqueue('b');
cout << myQueue.dequeue();
cout << myQueue.dequeue();

打印ab"這是為什么?

prints "ab" why is this?

似乎 cout 首先調用最外層(最接近 ;)的函數并按其方式工作,這是它的行為方式嗎?

It seems as though cout is calling the outermost (closest to the ;) function first and working its way in, is that the way it behaves?

推薦答案

<< 運算符沒有序列點,因此編譯器可以自由地評估 dequeue> 功能第一.保證的是第二個 dequeue 調用的結果(按照它在表達式中出現的順序,不一定是它的計算順序)是 <<<< 的第一個結果(如果你明白我在說什么).

There's no sequence point with the << operator so the compiler is free to evaluate either dequeue function first. What is guaranteed is that the result of the second dequeue call (in the order in which it appears in the expression and not necessarily the order in which it is evaluated) is <<'ed to the result of <<'ing the first (if you get what I'm saying).

因此編譯器可以自由地將您的代碼翻譯成任何類似的東西(偽中間 C++).這并不是一份詳盡的清單.

So the compiler is free to translate your code into some thing like any of these (pseudo intermediate c++). This isn't intended to be an exhaustive list.

auto tmp2 = myQueue.dequeue();
auto tmp1 = myQueue.dequeue();
std::ostream& tmp3 = cout << tmp1;
tmp3 << tmp2;

auto tmp1 = myQueue.dequeue();
auto tmp2 = myQueue.dequeue();
std::ostream& tmp3 = cout << tmp1;
tmp3 << tmp2;

auto tmp1 = myQueue.dequeue();
std::ostream& tmp3 = cout << tmp1;
auto tmp2 = myQueue.dequeue();
tmp3 << tmp2;

這是原始表達式中臨時詞對應的內容.

Here's what the temporaries correspond to in the original expression.

cout << myQueue.dequeue() << myQueue.dequeue();
|       |               |    |               |
|       |____ tmp1 _____|    |_____ tmp2 ____|
|                       |
|________ tmp3 _________|

這篇關于cout&lt;&lt;調用它打印的函數的順序?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Algorithm to convert RGB to HSV and HSV to RGB in range 0-255 for both(將 RGB 轉換為 HSV 并將 HSV 轉換為 RGB 的算法,范圍為 0-255)
How to convert an enum type variable to a string?(如何將枚舉類型變量轉換為字符串?)
When to use inline function and when not to use it?(什么時候使用內聯函數,什么時候不使用?)
Examples of good gotos in C or C++(C 或 C++ 中好的 goto 示例)
Significance of ios_base::sync_with_stdio(false); cin.tie(NULL);(ios_base::sync_with_stdio(false) 的意義;cin.tie(NULL);)
Is TCHAR still relevant?(TCHAR 仍然相關嗎?)
主站蜘蛛池模板: 国产精品乱码一区二区三区 | 一区久久| www一级片 | 4438xxx| 黄色片中文字幕 | 自拍偷拍欧美日韩 | 韩日中文字幕 | 俺去俺来也在线www色官网 | 日日夜夜噜 | 精品国产99| 天天干天天操天天 | 国产在线黄色 | 亚洲视频在线看 | 少妇视频网站 | 美日韩精品 | 中文字幕第一区 | 精品亚洲一区二区三区四区五区 | 无毒不卡| 国产黄色精品 | 日本女人性生活视频 | 国产亚洲欧美日韩高清 | 九九热在线观看 | 亚洲av毛片成人精品 | 一区二区视频在线播放 | 神马午夜视频 | 两性午夜视频 | 国产视频a | 亚洲国产精品久久久久久 | 免费91网站 | 精品一区久久 | 一区二区在线视频 | 中文字幕一区二区三区视频 | 日韩av在线免费 | 国产精品99999 | 欧美日韩国产中文字幕 | 国产欧美久久久 | 欧美久久一区 | 免费在线小视频 | 成人在线播放视频 | 亚洲啪啪网 | 国产二区精品 |