In C++ what causes an assignment to evaluate as true or false when used in a control structure?

前端 未结 6 2012
后悔当初
后悔当初 2020-11-29 11:46

So can someone help me grasp all the (or most of the relevant) situations of an assignment inside something like an if(...) or while(...), etc?

What I mean is like:<

6条回答
  •  没有蜡笔的小新
    2020-11-29 12:00

    The return type of the assignment is the left hand value, it's what allows statements like a = b = c to compile. In your example:

    while(a = &c)
    {
    }
    

    Returns true when "a" is true, after it has been assigned the value of &c.

提交回复
热议问题