是取消引用指针有效左值? [英] Is a dereferenced pointer a valid lvalue?

查看:92
本文介绍了是取消引用指针有效左值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设定义:

  INT I = 10;
为int * p =&放;我;

为什么* P一个有效左值这里:

  * P + = 10;

应该不是* P计算为贮存于放大器的整型值;我,即得。 10,因此产生了不是左值的错误?


解决方案

  

左值是指一个地区的前pression
  存储的能够被操纵


* P 就是这样一个前pression指向存储的区域。这比说 10 + = 10个不同的; ,因为 10 并非当然pression,它是一个整数文字。

Assuming the definition:

int i  = 10;
int *p = &i;

Why is *p a valid lvalue here:

*p+=10; 

Shouldn't *p evaluate to the value of the int stored at &i, ie. 10, and hence generate a "Not an lvalue" error?

解决方案

An lvalue is an expression that refers to a region of storage that can be manipulated.

*p is such an expression that refers to a region of storage. This is different than say 10+=10; because 10 is not an expression, it is an integer literal.

这篇关于是取消引用指针有效左值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆