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! ËùÒÔ, ÕâÊÇ´íÎóµÄ¸³Öµ
Ïà¹ØÎĵµ£º
ÕâÁ½Ì죬¸ø×Ô¼ºµçÄÔŪÁË˫ϵͳ£¬³ýÁËÔÀ´µÄWindows 7ϵͳÍ⣬װÉÏÁËLinuxϵͳ£¬Ê¹Óõİ汾ÊÇUbuntu
£¨µã
»÷¿Éµ½ÏàÓ¦µÄÏÂÔØÒ³Ãæ£©¡£¿ªÊ¼ÎÒ×°µÄLinux°æ±¾ÊÇfedora9£¬¶ÔÓÚÒ»¸ö¸ù±¾Ã»½Ó´¥¹ýLinuxϵͳµÄÈ˶øÑÔ£¬Ê¹ÓÃfedora£¬¼òÖ±ÈÃÈ˱ÀÀ£¡£¸ü
±ÀÀ£µÄÊÇ£¬ÎÒÓõÄÓ¢Îİ档ûµÄ°ì·¨£¬ÓÖÖØÐÂÏÂÔØLinux£¬¿Ìµú¡£×°ÏµÍ³¡£×°ÏµÍ³µÄʱºò ......
B/S½á¹¹£¨Browser/Server½á¹¹£©½á¹¹¼´ä¯ÀÀÆ÷ºÍ·þÎñÆ÷½á¹¹¡£ËüÊÇËæ×ÅInternet¼¼ÊõµÄÐËÆð£¬¶ÔC/S½á¹¹µÄÒ»Öֱ仯»òÕ߸ĽøµÄ½á¹¹¡£ÔÚÕâÖֽṹÏ£¬Óû§¹¤×÷½çÃæÊÇͨ¹ýWWWä¯ÀÀÆ÷À´ÊµÏÖ£¬¼«ÉÙ²¿·ÖÊÂÎñÂß¼ÔÚǰ¶Ë£¨Browser£©ÊµÏÖ£¬µ«ÊÇÖ÷ÒªÊÂÎñÂß¼ÔÚ·þÎñÆ÷¶Ë£¨Server£©ÊµÏÖ£¬ÐγÉËùνÈý²ã3-tier½á¹¹¡£ÕâÑù¾Í´ó´ó¼ò»¯Á˿ͻ§¶ËµçÄÔÔØ ......
µÚÒ»Õ CÓïÑÔ¸ÅÊö
²»ÒªÌÖÂÛΪʲôҪѧϰCÓïÑÔµÄÎÊÌ⣬CÓïÑÔ×ÔÓÐËü×Ô¼º¶ÀÌØµÄÆøÏ¢£¡
Ò»¡¢CÓïÑÔµÄÀúÊ·
CÓïÑÔÊÇ1972ÄêÖÁ1973Äê¼ä£¬ÔÚÃÀ¹úµÄ±´¶ûʵÑéÊÒ( Bell Laboratories )ÓÉDennis M. RitchieÒ»¸öÈË¿ª·¢³öÀ´µÄÒ»ÖÖÏà¶Ô±È½ÏеijÌÐòÉè¼ÆÓïÑÔ¡£
1960Ä꣬³öÏÖµÄALGOL 60 (Ò²³Æ A ÓïÑ ......
ÍøÉÏÓÐºÃ¶àÆªÎÄÕ½²ÈçºÎÅäÖÃ.vimrcÎļþÀ´ÊµÏÖVIMÀïÒ»¼ü±àÒ룬¿´ÁËһϱȽϸ´ÔÓ¡£ÎÒÒ»°ãûÓÐʲô´óµÄ³ÌÐòҪд£¬Ò»°ãµÄС³ÌÐòµ¥¸öCÎļþ¾Í¸ãµàÁË£¬ËùÒÔ¼ò»¯ÁËÒ»ÏÂÍøÉϵÄÅäÖã¬ÔÚ.vimrcÀï¼ÓÉÏÁ½ÐоÍÂú×ãÎÒµÄÐèÇóÁË¡£
set makeprg=gcc\ -Wall\ -o\ %<\ %
map <F7> :make<CR ......