c – 左值转换的左值

前端之家收集整理的这篇文章主要介绍了c – 左值转换的左值前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
从4.1 / 2

The value contained in the object indicated by the lvalue is the
rvalue result. When an lvalue-to-rvalue conversion occurs within the
operand of sizeof (5.3.3) the value contained in the referenced object
is not accessed,since that operator does not evaluate its operand.

出于好奇,我想知道,同样适用于if,for,while语句,即当评估语句的结果时,左值是否转换为右值?

解决方法

是.没有左值到右值的转换,它无法读取它的值.

简而言之,将左值作为某种容器,将rvalue视为容器中包含的值.

C 03,第3.10 / 7节,

Whenever an lvalue appears in a context where an rvalue is expected,the lvalue is converted to an rvalue; see 4.1,4.2,and 4.3.

请阅读§4.1/ 2(您的报价),

The value contained in the object indicated by the lvalue is the rvalue result.

相关主题

> What standard clause mandates this lvalue-to-rvalue conversion?

原文链接:https://www.f2er.com/c/110429.html

猜你在找的C&C++相关文章