“l-value required” error

前端 未结 11 2149
离开以前
离开以前 2020-12-10 00:06

When do we get \"l-value required\" error...while compiling C++ program???(i am using VC++ )

11条回答
  •  -上瘾入骨i
    2020-12-10 01:01

    R Value is an expression that always appear on right side of an assignment operator Eg:

    int a = 5;//here 5 is Rvalue

    L Value is an expression that can either come on left or right side of an assignment.When it is in on left side it refers to a place that can hold a value.

    Here a in expression a = 5 is L Value

    and when appearing on right side value is read from the L Value. Since R value which does not have capability to locate any memory it cannot hold any value like LValue so

    5 = 6 or 5 = a

    will be compiler error.

提交回复
热议问题