C++;带括号的表达式 我发现C++中可以做这样的事情:< /P> int a = ({ int x = 12 + 3; x*x + 7; }); bool x[] = {false, true, true, true, false}; if (({bool b = false; for (int i; i < 5; i++) if (x[i]) b = !b; b;})) printf("aaaaaaa\n"); int a = ({if (2 > 1) return x; x*x;});

C++;带括号的表达式 我发现C++中可以做这样的事情:< /P> int a = ({ int x = 12 + 3; x*x + 7; }); bool x[] = {false, true, true, true, false}; if (({bool b = false; for (int i; i < 5; i++) if (x[i]) b = !b; b;})) printf("aaaaaaa\n"); int a = ({if (2 > 1) return x; x*x;});,c++,C++,或者像这样: int a = ({ int x = 12 + 3; x*x + 7; }); bool x[] = {false, true, true, true, false}; if (({bool b = false; for (int i; i < 5; i++) if (x[i]) b = !b; b;})) printf("aaaaaaa\n"); int a = ({if (2 > 1) return x; x*x;}); 也不是 也不是

或者像这样:

int a = ({
    int x = 12 + 3;
    x*x + 7;
});
bool x[] = {false, true, true, true, false};
if (({bool b = false; for (int i; i < 5; i++) if (x[i]) b = !b; b;}))
    printf("aaaaaaa\n");
int a = ({if (2 > 1) return x; x*x;});
也不是

也不是


是什么?从什么时候开始允许了?在关闭括号前如何返回结果?< /p> < p>这是一个语言扩展,不是标准C++。< /p> 这是一个语言扩展。看见不要用它