萌新瑟瑟发抖的 2022-02-07 18:52 采纳率: 85.3%
浏览 106
已结题

为什么错误是表达式不是可修改的左值

img

  • 写回答

5条回答 默认 最新

  • _GX_ 2022-02-07 19:19
    关注

    因为b的类型是int(*)[2]b[i]的类型是int [2],是一个数组类型,C/C++不允许对一个数组类型直接赋值。
    b[i] = a[i]改为b=a,这里是指针赋值

    FROM https://en.cppreference.com/w/cpp/language/array#Assignment

    Objects of array type cannot be modified as a whole: even though they are lvalues (e.g. an address of array can be taken), they cannot appear on the left hand side of an assignment operator:

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(4条)

报告相同问题?

问题事件

  • 系统已结题 2月16日
  • 已采纳回答 2月8日
  • 创建了问题 2月7日