C/C++ 之 left operand must be l-value 错误提示总结
来源:互联网 发布:it学徒 编辑:程序博客网 时间:2024/06/05 00:46
编译器:vc6.0
语言:c/c++
= : left operand must be l-value 到底是什么错误?
解释:赋值号(‘=’)左边的操作数必须是一个左值。通俗的说:左值就是可以改变的值的变量。
发生这个错误的原因是你把常量(或不可改变值的变量)放到了赋值号的左边。
例如:int a[3];
a++;//这里就相当于a=a+1;注意a是数组a[3]的首地址,在声明a[3]后,将开辟一段连续内存空间。
//就是这段连续内存空间的首地址,是一个常量。所以这里将常量放到了赋值号的左边是错误。
//类似的,在C语言中是不可以写2++;的。
例如:const int num=5;
int b=3;
num=b+4;//这里num为不可改变的值,不能放到赋值号的左边。
总结:赋值号左边的值只能是左值。而上面两个例子中的a,num都不是左值,所以在编译时会出错。
关于 修改
int (*a)[3] = new int[2][3];
a[0] = {1,2,3};
a[1] = {11,22,33};
出现的相应报错的解决办法:
1)循环语句 逐个赋值 ;
2)整体赋值
int (*a)[3] = new int[2][3];
int tmp[2][3] = {{1,2,3},{4,5,6}};
a = tmp;
0 0
- C/C++ 之 left operand must be l-value 错误提示总结
- left operand must be l-value 错误提示总结
- left operand must be l-value
- left operand must be l-value(左边的操作符必须是可赋值的变量)
- 513. Find Bottom Left Tree Value(C++)
- Android奇怪错误---java.lang.NumberFormatException: Color value '@drawable/C-t' must start with ‘#’
- the left operand of ** is a garbage value
- the left operand of ** is a garbage value
- the left operand of * is a garbage value
- C#Connection must be valid and open?
- must be in segment block c
- Python之Headers value 1 must be of type str or bytes, not <class 'int'>错误的解决
- ImageLoader must be init with configuration before using 错误解决方法c
- 关于Length parameter must be greater than 0错误提示
- attribute value must be constant
- 11-19 秦皇岛重现赛水题总结之c,l,m
- unexpected token after objective c string 和@ end must be appear in an objective c context 错误
- glog函数调用出现c++:void value not ignored as it ought to be错误
- JAVA泛型的基本使用
- 粘性session和非粘性session的区别:
- oracle 动态sql select into
- Java实现的快速排序算法
- LightNvm - Linux Kernel support for Open-channel SSDs
- C/C++ 之 left operand must be l-value 错误提示总结
- 使用ImageLoad开源库ListView图片错位问题
- 流行的Go语言web框架简介
- JPA基础思路
- 浅谈git
- Android 滑动切换Activity动画效果
- c++抽象类和纯虚函数 知识整理
- SAS 代码合集
- 24. Swap Nodes in Pairs