C/C++ÖÐ×óÖµºÍÓÒÖµµÄ²î±ð
ÎÒÃdz£ËµµÄ×óÖµlvalueºÍÓÒÖµrvalue²¢²»¼òµ¥µØÒâζ×Å×óÓÒÇø±ð£¬ËüµÄÔʼ¶¨ÒåÈçÏ£º
Definition:
C and C++ have the notion of lvalues and rvalues associated with
variables and constants. The rvalue is the data value of the variable,
that is, what information it contains. The "r" in rvalue can be thought of as "read"
value
. A variable also has an associated lvalue. The "l" in lvalue can be though of as location
,
meaning that a variable has a location that data or information can be
put into. This is contrasted with a constant. A constant has some data
value, that is an rvalue. But, it cannot be written to. It does not
have an lvalue.
Another view of these terms is that objects with an rvalue, namely a
variable or a constant can appear on the right hand side of a
statement. They have some data value that can be manipulated. Only
objects with an lvalue, such as variable, can appear on the left hand
side of a statement. An object must be addressable to store a value.
Here are two examples.
int x;
x = 5; // This is fine, 5 is an rvalue, x can be an lvalue.
5 = x; // This is illegal. A literal constant such as 5 is not
// addressable. It cannot be a lvalue.
ÒýÎÄÖÐ˵: "The "r" in rvalue can be thought of as "read" value."
¾ÍÊÇÄã¿ÉÒÔ°Ñ "r" Àí½âΪ "read". ²¢Ã»ÓÐ˵¾ÍÊÇ "read" µÄÒâ˼!
lvalue, rvalue³ÆÎª"×óÖµ", "ÓÒÖµ" ²¢Ã»ÓÐÎ¥±³ÔÒâ. ÒòΪ,
µ½Ä¿Ç°ÎªÖ¹, ËùÓмÆËã»úÓïÑÔ¶¼Êǽ«±»¸³ÖµÁ¿ÖÃÓÚ¸³ÖµºÅ×ó¶ËµÄ, Òò´ËÕâÖÖ³ÆÎ½ºÍÀí½â·Ç³£Ö±¹ÛµÄ. ¶ÔÓÚ¸³ÖµÁ¿À´Ëµ, Ò²ÊÇÏàͬµÄµÀÀí.
Ö®ËùÒÔÓÐ"location"ºÍ"read"µÄ˵·¨, ÊÇÒòΪÔÚC/C++ÖÐ, Óкܶà±í´ïʽÊDZí´ï¿É¸³Öµµ¥ÔªµÄ,
ÎÒÃDz»Äܼòµ¥µØÀí½â"lvalue"¾ÍÊDZäÁ¿. Èç: a[i], *p, *(a->p+1), µÈµÈ. ÕâЩ¶¼ÊÇC/C++µÄ±í´ïʽ,
²»ÊDZäÁ¿, ¹ÊÓÃ"location"µÄº¬Òå¿ÉÒÔ±ÜÃâºÜ¶àÎó½â. Çë¿´ÏÂÃæµÄÀý×Ó:
const int x;
x = 1; // ÕâÀï x ÊÇ rvalue! ËùÒÔ, ÕâÊÇ´íÎóµÄ¸³Öµ
Ïà¹ØÎĵµ£º
ÔÚÕ⼸ÌìµÄ¹¤×÷¹ý³ÌÖУ¬ÐèҪʵÏÖPHPÔÚ·þÎñÆ÷¶ËÄÜÓëÆäËû³ÌÐòͨÐÅ¡£ºÍÀϺÎÁ©ÈËÑо¿Á˰ëÌ죬ÖÕÓÚ´óÖÂŪ³öÁËÒ»¸öÓÃWINDOWSµÄÃüÃû¹ÜµÀͨÐŵķ½·¨¡£
Óм¸µãÐèҪעÒâµÄ£º
PHP·þÎñÆ÷¶ËÎÒÃÇÿ´Î¶¼ÊÇÖØÐ¹ҽÓÃüÃû¹ÜµÀ¡££¨ÕâÑùд£¬PHP¶Ë´úÂëÁ¿¼«ÆäÉÙ£¬¶øÇÒÒ²ºÜ·½±ã¡££©
ÄÇôÎÒÃÇÓÃC/C++дµÄÃüÃû¹ÜµÀ·þÎñÆ÷ÔòÐèҪÿ´ÎͨÐŶ¼´´½¨Ò»´Î¹ ......
ÕâÁ½Ì죬¸ø×Ô¼ºµçÄÔŪÁË˫ϵͳ£¬³ýÁËÔÀ´µÄWindows 7ϵͳÍ⣬װÉÏÁËLinuxϵͳ£¬Ê¹Óõİ汾ÊÇUbuntu
£¨µã
»÷¿Éµ½ÏàÓ¦µÄÏÂÔØÒ³Ãæ£©¡£¿ªÊ¼ÎÒ×°µÄLinux°æ±¾ÊÇfedora9£¬¶ÔÓÚÒ»¸ö¸ù±¾Ã»½Ó´¥¹ýLinuxϵͳµÄÈ˶øÑÔ£¬Ê¹ÓÃfedora£¬¼òÖ±ÈÃÈ˱ÀÀ£¡£¸ü
±ÀÀ£µÄÊÇ£¬ÎÒÓõÄÓ¢Îİ档ûµÄ°ì·¨£¬ÓÖÖØÐÂÏÂÔØLinux£¬¿Ìµú¡£×°ÏµÍ³¡£×°ÏµÍ³µÄʱºò ......
windows7 + ubuntu9.10Ë«Æô¶¯,Õâ¸öÓÐÌ«¶àµÄÌû×ÓÁË,²»¹ýÕâ´ÎµÄÇé¿ö±È½Ï¸´ÔÓ.
ÏÈ×°µÄWIN7,ºó×°UBUNTU,ûÓÐÈκÎÎÊÌâ.GRUBË«Æô¶¯.
ºóÀ´ÒòΪһ¸öÇé¿ö,ҪװXP,°ÑWIN7×öÁË ghost.×°ÍêXP,GRUBµ±È»Ã»ÓÐÁË,ÓÚÊÇÓÃubuntuÆô¶¯ÅÌÐÞ¸´.
ËäÈ»Æô¶¯²Ëµ¥³öÀ´ÁË,µ«Ö»ÄܽøÐÐubuntu,½øÈëwindowsµÄʱºò¾ÍÌáʾerror:cannot get C/H/S value ......
cѧµÄÈ˺ܶࡣµ«Ê®Ö®°Ë¾ÅÊǰëͰˮ¡£»òÕßдµÃºÜËÀ¡£Ò²ÐíÎÒÕâ»°ÓÐµãÆ«¼¤¡£µ«ÊÇÎÒ¸ø³öÒ»¸ö±ê×¼°É¡£ÄãÄÜд³öÏñlinuxÄں˴úÂëÕâÑùµÄ´úÂëÂð£¿ÆäʵÈκÎÒ»ÃÅÓïÑԵľ«Ë裬ÔÚÓÚÔËÓá£ËùÒÔÔÚѧϰ֮ǰ×îºÃÎÊÒ»ÎÊÎÒΪʲҪѧÕâÃÅÓïÑÔ¡£Èç¹ûÊÇΪѧ¶øÑ§£¬Ñ§µ½×îºóÓÖÊǰëͰˮ¡£»¹ÕæµÄ²»È翴С˵À´µÃ´Ì¼¤¡£Ã»ÓÐÄ¿µÄ¸ÉÊÂÇ飬±¾Éí¾ÍÊÇÒ»ÖÖÀË·Ñ¡£ ......