C/C++ӦƸ×ܽá[ÌرðÍƼö¸ø´óÈýµÄѧµÜѧÃÃÃÇ]
¸ãÈí¼þÊÇÓиãÍ·µÄ
——×ÞÆî·å
2009Äê12ÔÂ3ÈÕ
ÉùÃ÷£ºËù˵µÄÖ»Õë¶ÔC¡¢C++¡¢.NETרҵµÄͬѧ£¬¶ÔÆäËûרҵҲÐíûÓвο¼¼ÛÖµ£¡
[ÍƼö¸ø´óÈýµÄѧµÜѧÃÃÃÇ]
¡¾»¶Ó¸÷λÅóÓѲ¹³ä¡¿
¶ÔÎÒ¸öÈ˶øÑÔ£¬´óѧ±ÏÒµÕÒ¹¤×÷ËãÊÇ»ÉÏÁËÒ»¸öÐí¶àÈËÏÛĽ£¬µ«ÎÒ×Ô¼ºÈÔ¸ÐÒź¶µÄ¾äºÅ¡£ÕÒ¹¤×÷ÆÚ¼äÎÒ¾ÀúµÄºÜ¶àÊÂÇ飬ÈÃÎÒѧµ½Á˺ܶ࣬Ҳ³É³¤Á˺ܶࡣ
ÎҺʹó¼ÒÒ»Ñù£¬Í¬ÑùÊǾÀú¹ý¸ß¿¼£¬È»ºó¾Àú¹ý´óѧ¼¸ÄêµÄѧϰ£¬×îÖÕÒ²ºÍ´ó¼ÒÒ»Ñù×ß³öУÃÅ×ß½øÉç»á¡£ÕÒ¹¤×÷ÆÚ¼ä¾ÀúµÄºÜ¶àÊÂÇ飬Ҳ×ܽá³öÁ˺ܶණÎ÷£¬¾õµÃ¶ÔÕýÔÚÕÒ¹¤×÷µÄͬѧ¡¢ÅóÓÑÒÔ¼°ÌرðÊÇ´¦ÓÚÃÔãÆڵĴóÈýµÄѧµÜѧÃÃÃÇ»òÐíÓÐЩ°ïÖú¡£¸Ð¾õ²»Ð´³öÀ´£¬²»¸æËßÆäËûºÍÏàËƾÀúµÄÅóÓÑ£¬ÄÇÌ«¿Éϧ¡¢Ì«ÀË·ÑÁË¡£ÒòΪÎÒ¾õµÃÕâÊÇÒ»±Ê²Æ¸»£¬Ò»±Ê´ó¼Ò¿ÉÒÔ¹²Í¬·ÖÏíµÄ²Æ¸»£¡
ÓɽñÄêÕÐƸµÄ×ÜÌåÇé¿öÀ´¿´£¬ÕÐÏúÊÛºÍITµÄ±È½Ï¶à£¬µ«Ñ§ITÏà¹ØרҵµÄͬѧ´¦ÓÚ³¬±¥ºÍ״̬£¬ËùÒÔ¾ºÕùҲʮ·Ö¼¤ÁÒ£¬ÍùÍù»á³öÏÖÒ»¸öÈË¿ÉÒÔÄúܶàOFFER£¬¶øºÜ¶àÈËÈ´Ò»¸öOFFER¶¼Ã»ÓУ¨¼´£¬Ê§ÒµµÄÒ²¶à£¡£©¡£´Ó¹¤×ÊˮƽÀ´¿´£¬´ÓÊÂITÐÐÒµµÄÔ±¹¤¹¤×ʱÈÆäËûÐÐÒµµÄ¹¤×ÊÒª¸ßºÜ¶à¡£ITÐÐÒµÖÐÓÖ·ÖÕÐÈí¼þ¿ª·¢ÈËÔ±ºÍÈí¼þ²âÊÔÈËÔ±£¬ÆäÖÐÈí¼þ¿ª·¢ÈËÔ±µÄ¹¤×ÊÒª¸ßһЩ£¬Èí¼þ²âÊÔµÄÐèÇóÁ¿Ò²ºÜ´ó£¨¹¤×ʵ±È»Ò²Í¦¸ßµÄ£©¡£½¨ÒéITÀàÅ®Éú¿ÉÒÔÈ¥¶à¶àѧϰ¹ØÓÚ²âÊÔ·½ÃæµÄ֪ʶ£¨×îºÃºÍÒѾÕÒµ½¸Ã·½Ïò¹¤×÷µÄѧ½ã½»Á÷һϣ©£¬ÒòΪ¿ª·¢Ààְλ¼¸ºõ²»ÕÐÅ®ÉúµÄ£¬µ«²âÊÔÕÐÅ®ÉúºÜ¶à£¡£¡£¡
.NETÏà¹ØְλËƺõ¶¼´¦ÓÚ±¥ºÍ״̬£¬ÍùÍùÊÇһЩ±È½ÏСµÄ¹«Ë¾ÕÐÒ»µã£¬¶øÇÒ¸øµÄ¹¤×ʶ¼±È½ÏµÄµÍ£¡µ«²»¹ÜÊÇ´ó¹«Ë¾»¹ÊÇС¹«Ë¾£¬¶ÔC/C++µÄÐèÇóÁ¿¶¼ºÜ´ó£¬¶øÇÒ¹¤×ʸøµÄÒ²±È½Ï¸ß£¬¶øÇÒ½øÈëµÄÍùÍù¶¼Êǹ«Ë¾µÄºËÐÄÑз¢²¿ÃÅ£¡
ÏÖÔÚÎÒÃÇÑÔ¹éÕý´«£¬¹«Ë¾ÕÐƸC/C++¹¤³ÌʦÖ÷Òª»á¿¼Õ⼸·½ÃæµÄÄÚÈÝ£ºÏÂÃæÎҾ͸ø´ó¼Ò·ÖÎöÒ»ÏÂÕ⼸ÃŹ«Ë¾Òª¿¼µÄÖ÷ÒªÄÚÈÝ£¬²¢ÍƼöһЩ×ÊÁϸø´ó¼Ò£¡
¢Ù C/C++£ºÖ÷Òª¿¼´ó¼ÒµÄ»ù´¡ÖªÊ¶£¡È磺±àÂë·ç¸ñ¡¢ÄÚ´æ¹ÜÀí£¨Ö¸Õë¡¢malloc¡¢free¡¢new¡¢delete£©¡¢ÀàÖ®¼äµÄÅÉÉúºÍ·ÃÎʹØϵ£¨Ð麯ÊýÐé¼Ì³Ð ÐéÎö¹¹µÄ×÷Óõȣ©¡¢¹Ø¼ü×Ö£¨static¡¢const¡¢voliate£©µÄ×÷Óá¢C++±ê׼ģ°å¿â¡¢CºÍC++µÄÇø±ðµÈµÈ¡£ÎÒ¸ø´ó¼ÒÍƼöÁ½±¾Ê飺¡¶³ÌÐòÔ±ÃæÊÔ±¦µä¡·ºÍ¡¶C/C++¸ßÖÊÁ¿³ÌÐòÉè¼Æ¡·£¬ÀïÃæ°üº¬Á˹«Ë¾×î°®µÄÌâÄ¿£¬±ÊÊÔµÄʱºò£¬ºÜ¶à¶¼ÊÇÀïÃæµÄÔÌ⣡ÕâÁ½±¾ÊéºÃ²»ºÃ£¬Ö»Óеȴó¼ÒÕÒ¹¤×÷µÄʱºò£¬»á¸ø³öÒ»¸ö¹«ÕýºÏÀíµÄÆÀ¼Û¡£
¢Ú Êý¾Ý½á¹¹£ºÎÒÏëÕâÊÇ´óѧÆÚ¼ä¹Ò¿ÆÂÊ×î¸ßµÄ¿Î³ÌÖ®Ò»£¬Õâ¸üÊǹ«
Ïà¹ØÎĵµ£º
C³ÌÐòÖоßÓзḻµÄÊý¾ÝÀàÐÍ£¬°üÀ¨ÉùÃ÷ÖÐÏÔʽ¶¨ÒåµÄÀàÐͺÍÓÃ×ö±í´ïʽÖмäÀàÐ͵ĵ¼³öÀàÐÍ¡£ÀýÈ磬ÏÂÃæµÄ¸³ÖµÓï¾ä°üº¬3 ÖÖ²»Í¬ÀàÐÍ:
int *p, x;
*p = x;
xÊÇÒ»¸ö´æ·ÅÕûÊýµÄµ¥ÔªµÄµØÖ·£¬Òò´ËxµÄµØÖ·µÄÀàÐÍÊÇ£ºÖ¸ÏòÒ»¸öÕûÊýµÄÖ¸Õë¡£xµÄÖµµÄÀàÐÍÊÇÕûÐÍ¡£Í¬Ñù, pµÄ×óÖµµÄÀàÐÍÊÇÖ¸ÏòÒ»¸öÕ ......
C·ç¸ñ×Ö·û´®£º¶Ô×Ö·û´®½øÐвÙ×÷µÄ C º¯Êý¶¨ÒåÔÚÍ·Îļþ<cstring>ÖУ»
1. ×Ö·û´®¶¨Ò壺char* result£»
2. ×Ö·û´®µÄ×îºóÒ»¸ö×Ö·ûÊÇnull×Ö·û£¨'\0'£©£¬¿ÉÒÔͨ¹ýÕâ¸ö×Ö·ûÈ·¶¨×Ö·û´®µÄ½áβ¡£
3. strlen()·µ»ØµÄÊÇ×Ö·û´®µÄ´óС£»Òò´Ë£¬ ......
cÓëc++ staticº¯ÊýµÄÇø±ð
±¾ÎÄת×Ô£ºhttp://blog.csdn.net/lipps/archive/2007/05/18/1615419.aspx
static¹Ø¼ü×ÖÊÇC, C++Öж¼´æÔڵĹؼü×Ö, ËüÖ÷ÒªÓÐÈýÖÖʹÓ÷½Ê½, ÆäÖÐÇ°Á½ÖÖÖ»Ö¸ÔÚCÓïÑÔÖÐʹÓÃ, µÚÈýÖÖÔÚC++ÖÐʹÓÃ(C,C++ÖоßÌåϸ΢²Ù×÷²»¾¡Ïàͬ, ±¾ÎÄÒÔC++Ϊ׼).
(1)¾Ö²¿¾²Ì¬±äÁ¿
(2)Íⲿ¾²Ì¬±ä ......
While looking for information on the subject, I looked into the ONLamp article Extending Ruby with C by Garrett Rooney, the Extending Ruby chapter in the Pickaxe, README.EXT (located at /usr/share/doc/ruby1.8-dev/README.EXT.gz on my Ubuntu system) and got some help from Kjetil.
The resulting file c ......