Defining a variable in the condition part of an if-statement?

前端 未结 5 460
夕颜
夕颜 2020-12-13 12:14

I was just shocked, that this is allowed:

if( int* x = new int( 20 ) )
{
    std::cout << *x << \"!\\n\";
    // delete x;
}
else
{
    std::cout         


        
5条回答
提交回复
热议问题