[英]What Does ({}); Mean in C++?
AFAIK {}
定義了一個新范圍,那么它定義了什么?
({});
編譯器很好地編譯了這個程序:
#include <iostream>
#include <string>
int main()
{
std::string name;
std::cout << "What is your name? ";
{
({});
}
getline (std::cin, name);
std::cout << "Hello, " << name << "!\n";
}
當我替換({});
with ();
編譯器無法編譯程序。
為什么({});
工作得很好,但();
才不是?
我在cpp.sh上測試了該程序。 它匯編得很好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.