Using ternary operator to initialize a reference variable?

前端 未结 2 924
无人共我
无人共我 2021-02-12 21:52

Putting all the maintainability and reading issues aside, can these lines of code generate undefined behavior?

float  a = 0, b = 0;
float& x = some_condition         


        
2条回答
  •  春和景丽
    2021-02-12 22:55

    No, it's just fine. It would not create undefined behavior in this code. You will just change value of a or b to 5, according to condition.

提交回复
热议问题