自己做网站还是用博客,中国国际园林博览会,wordpress文章标题高亮插件,新乡做新网站C左值和右值#xff0c;初学者经常傻傻分不清#xff0c;可参看“C Primer”书中的描述#xff0c;简单来说#xff1a;
当一个对象被用作右值的时候#xff0c;用的是对象的值#xff08;内容#xff09;#xff1b;当对象被用作左值的时候#xff0c;用的是对象的身…C左值和右值初学者经常傻傻分不清可参看“C Primer”书中的描述简单来说
当一个对象被用作右值的时候用的是对象的值内容当对象被用作左值的时候用的是对象的身份在内存中的位置。
一个重要的原则在需要右值的地方可以用左值来代替但是不能把右值当成左值也就是位置使用。当一个左值被当成右值使用时实际使用的是它的内容值。
还不明白的话参见MSDN关于“Lvalues and Rvalues”的描述
Every C expression is either an lvalue or an rvalue. An lvalue refers to an object that persists beyond a single expression. You can think of an lvalue as an object that has a name. All variables, including nonmodifiable (const) variables, are lvalues. An rvalue is a temporary value that does not persist beyond the expression that uses it. To better understand the difference between lvalues and rvalues.