ÓÑÇéÌáʾ£ºÈç¹û±¾ÍøÒ³´ò¿ªÌ«Âý»òÏÔʾ²»ÍêÕû£¬Çë³¢ÊÔÊó±êÓÒ¼ü¡°Ë¢Ð¡±±¾ÍøÒ³£¡ÔĶÁ¹ý³Ì·¢ÏÖÈκδíÎóÇë¸æËßÎÒÃÇ£¬Ð»Ð»£¡£¡ ±¨¸æ´íÎó
Ò»ÊÀÊé³Ç ·µ»Ø±¾ÊéĿ¼ ÎÒµÄÊé¼Ü ÎÒµÄÊéÇ© TXTÈ«±¾ÏÂÔØ ½øÈëÊé°É ¼ÓÈëÊéÇ©

¸ßÖÊÁ¿c++±à³ÌÖ¸ÄÏ-µÚ9ÕÂ

°´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·­Ò³£¬°´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ£¬°´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿£¡
¡ª¡ª¡ª¡ªÎ´ÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡



óÀ´ÎÒ¸ÄдÁËÕâ¸öÈí¼þ£¬´úÂëÁ¿ËõСµ½Ô­ÏȵÄÒ»°ë¡£
¡¡¡¡Îҵľ­Ñé½ÌѵÊÇ£º
£¨1£©Ô½ÊÇÅÂÖ¸Õ룬¾ÍԽҪʹÓÃÖ¸Õë¡£²»»áÕýȷʹÓÃÖ¸Õ룬¿Ï¶¨Ëã²»ÉÏÊǺϸñµÄ³ÌÐòÔ±¡£
£¨2£©±ØÐëÑø³É¡¨Ê¹Óõ÷ÊÔÆ÷Ö𲽸ú×Ù³ÌÐò¡¨µÄϰ¹ß£¬Ö»ÓÐÕâÑù²ÅÄÜ·¢ÏÖÎÊÌâµÄ±¾ÖÊ¡£

µÚ8Õ¡¡C£«£«º¯ÊýµÄ¸ß¼¶ÌØÐÔ
¡¡¡¡¶Ô±ÈÓÚCÓïÑԵĺ¯Êý£¬C£«£«Ôö¼ÓÁËÖØÔØ£¨overloaded£©¡¢ÄÚÁª£¨inline£©¡¢constºÍvirtualËÄÖÖлúÖÆ¡£ÆäÖÐÖØÔØºÍÄÚÁª»úÖÆ¼È¿ÉÓÃÓÚÈ«¾Öº¯ÊýÒ²¿ÉÓÃÓÚÀàµÄ³ÉÔ±º¯Êý£¬constÓëvirtual»úÖÆ½öÓÃÓÚÀàµÄ³ÉÔ±º¯Êý¡£
ÖØÔØºÍÄÚÁª¿Ï¶¨ÓÐÆäºÃ´¦²Å»á±»C£«£«ÓïÑÔ²ÉÄÉ£¬µ«ÊDz»¿ÉÒÔµ±³ÉÃâ·ÑµÄÎç²Í¶øÀÄÓᣱ¾Õ½«Ì½¾¿ÖØÔغÍÄÚÁªµÄÓŵãÓë¾ÖÏÞÐÔ£¬ËµÃ÷ʲôÇé¿öÏÂÓ¦¸Ã²ÉÓᢲ»¸Ã²ÉÓÃÒÔ¼°Òª¾¯Ìè´íÓá£
8¡£1¡¡º¯ÊýÖØÔØµÄ¸ÅÄî
8¡£1¡£1¡¡ÖØÔØµÄÆðÔ´
×ÔÈ»ÓïÑÔÖУ¬Ò»¸ö´Ê¿ÉÒÔÓÐÐí¶à²»Í¬µÄº¬Ò壬¼´¸Ã´Ê±»ÖØÔØÁË¡£ÈËÃÇ¿ÉÒÔͨ¹ýÉÏÏÂÎÄÀ´Åжϸôʵ½µ×ÊÇÄÄÖÖº¬Òå¡£¡¨´ÊµÄÖØÔØ¡¨¿ÉÒÔʹÓïÑÔ¸ü¼Ó¼òÁ·¡£ÀýÈ硨³Ô·¹¡¨µÄº¬ÒåÊ®·Ö¹ã·º£¬ÈËÃÇûÓбØÒªÃ¿´Î·ÇµÃ˵Çå³þ¾ßÌå³Ôʲô²»¿É¡£±ðÓØ¸¯µÃÏó¿×ÒѼº£¬ËµÜîÏã¶¹µÄÜî×ÖÓÐËÄÖÖд·¨¡£
ÔÚC£«£«³ÌÐòÖУ¬¿ÉÒÔ½«ÓïÒå¡¢¹¦ÄÜÏàËÆµÄ¼¸¸öº¯ÊýÓÃͬһ¸öÃû×Ö±íʾ£¬¼´º¯ÊýÖØÔØ¡£ÕâÑù±ãÓÚ¼ÇÒ䣬Ìá¸ßÁ˺¯ÊýµÄÒ×ÓÃÐÔ£¬ÕâÊÇC£«£«ÓïÑÔ²ÉÓÃÖØÔØ»úÖÆµÄÒ»¸öÀíÓÉ¡£ÀýÈçʾÀý8¡­1¡­1Öеĺ¯ÊýEatBeef£»EatFish£»EatChicken¿ÉÒÔÓÃͬһ¸öº¯ÊýÃûEat±íʾ£¬Óò»Í¬ÀàÐ͵IJÎÊý¼ÓÒÔÇø±ð¡£

¡¡¡¡
¡¡¡¡void¡¡EatBeef£¨¡£¡£¡££©£»¡¡¡¡¡¡¡¡¡¡¡¡¡¡//¡¡¿ÉÒÔ¸ÄΪ¡¡¡¡¡¡¡¡¡¡void¡¡Eat£¨Beef¡¡¡£¡£¡££©£»
¡¡¡¡void¡¡EatFish£¨¡£¡£¡££©£»¡¡¡¡¡¡¡¡¡¡¡¡¡¡//¡¡¿ÉÒÔ¸ÄΪ¡¡¡¡¡¡¡¡¡¡void¡¡Eat£¨Fish¡¡¡£¡£¡££©£»
¡¡¡¡void¡¡EatChicken£¨¡£¡£¡££©£»¡¡¡¡¡¡¡¡//¡¡¿ÉÒÔ¸ÄΪ¡¡¡¡¡¡¡¡¡¡void¡¡Eat£¨Chicken¡¡¡£¡£¡££©£»
¡¡¡¡
ʾÀý8¡­1¡­1¡¡ÖØÔغ¯ÊýEat

C£«£«ÓïÑÔ²ÉÓÃÖØÔØ»úÖÆµÄÁíÒ»¸öÀíÓÉÊÇ£ºÀàµÄ¹¹Ô캯ÊýÐèÒªÖØÔØ»úÖÆ¡£ÒòΪC£«£«¹æ¶¨¹¹Ô캯ÊýÓëÀàͬÃû£¨Çë²Î¼ûµÚ9Õ£©£¬¹¹Ô캯ÊýÖ»ÄÜÓÐÒ»¸öÃû×Ö¡£Èç¹ûÏëÓü¸ÖÖ²»Í¬µÄ·½·¨´´½¨¶ÔÏó¸ÃÔõô°ì£¿±ðÎÞÑ¡Ôñ£¬Ö»ÄÜÓÃÖØÔØ»úÖÆÀ´ÊµÏÖ¡£ËùÒÔÀà¿ÉÒÔÓжà¸öͬÃûµÄ¹¹Ô캯Êý¡£

8¡£1¡£2¡¡ÖØÔØÊÇÈçºÎʵÏֵģ¿
¼¸¸öͬÃûµÄÖØÔØº¯ÊýÈÔÈ»ÊDz»Í¬µÄº¯Êý£¬ËüÃÇÊÇÈçºÎÇø·ÖµÄÄØ£¿ÎÒÃÇ×ÔÈ»Ïëµ½º¯Êý½Ó¿ÚµÄÁ½¸öÒªËØ£º²ÎÊýÓë·µ»ØÖµ¡£
¡¡¡¡Èç¹ûͬÃûº¯ÊýµÄ²ÎÊý²»Í¬£¨°üÀ¨ÀàÐÍ¡¢Ë³Ðò²»Í¬£©£¬ÄÇôÈÝÒ×Çø±ð³öËüÃÇÊDz»Í¬µÄº¯Êý¡£
¡¡¡¡Èç¹ûͬÃûº¯Êý½ö½öÊÇ·µ»ØÖµÀàÐͲ»Í¬£¬ÓÐʱ¿ÉÒÔÇø·Ö£¬ÓÐʱȴ²»ÄÜ¡£ÀýÈ磺
¡¡¡¡void¡¡Function£¨void£©£»
¡¡¡¡int¡¡¡¡Function¡¡£¨void£©£»
ÉÏÊöÁ½¸öº¯Êý£¬µÚÒ»¸öûÓзµ»ØÖµ£¬µÚ¶þ¸öµÄ·µ»ØÖµÊÇintÀàÐÍ¡£Èç¹ûÕâÑùµ÷Óú¯Êý£º
int¡¡¡¡x¡¡=¡¡Function¡¡£¨£©£»
Ôò¿ÉÒÔÅжϳöFunctionÊǵڶþ¸öº¯Êý¡£ÎÊÌâÊÇÔÚC£«£«/C³ÌÐòÖУ¬ÎÒÃÇ¿ÉÒÔºöÂÔº¯ÊýµÄ·µ»ØÖµ¡£ÔÚÕâÖÖÇé¿öÏ£¬±àÒëÆ÷ºÍ³ÌÐòÔ±¶¼²»ÖªµÀÄĸöFunctionº¯Êý±»µ÷Óá£
ËùÒÔÖ»ÄÜ¿¿²ÎÊý¶ø²»ÄÜ¿¿·µ»ØÖµÀàÐ͵IJ»Í¬À´Çø·ÖÖØÔØº¯Êý¡£±àÒëÆ÷¸ù¾Ý²ÎÊýΪÿ¸öÖØÔØº¯Êý²úÉú²»Í¬µÄÄÚ²¿±êʶ·û¡£ÀýÈç±àÒëÆ÷ΪʾÀý8¡­1¡­1ÖеÄÈý¸öEatº¯Êý²úÉúÏó_eat_beef¡¢_eat_fish¡¢_eat_chickenÖ®ÀàµÄÄÚ²¿±êʶ·û£¨²»Í¬µÄ±àÒëÆ÷¿ÉÄܲúÉú²»Í¬·ç¸ñµÄÄÚ²¿±êʶ·û£©¡£

¡¡¡¡Èç¹ûC£«£«³ÌÐòÒªµ÷ÓÃÒѾ­±»±àÒëºóµÄCº¯Êý£¬¸ÃÔõô°ì£¿
¡¡¡¡¼ÙÉèij¸öCº¯ÊýµÄÉùÃ÷ÈçÏ£º
¡¡¡¡void¡¡foo£¨int¡¡x£»¡¡int¡¡y£©£»
¸Ãº¯Êý±»C±àÒëÆ÷±àÒëºóÔÚ¿âÖеÄÃû×ÖΪ_foo£¬¶øC£«£«±àÒëÆ÷Ôò»á²úÉúÏñ_foo_int_intÖ®ÀàµÄÃû×ÖÓÃÀ´Ö§³Öº¯ÊýÖØÔØºÍÀàÐͰ²È«Á¬½Ó¡£ÓÉÓÚ±àÒëºóµÄÃû×Ö²»Í¬£¬C£«£«³ÌÐò²»ÄÜÖ±½Óµ÷ÓÃCº¯Êý¡£C£«£«ÌṩÁËÒ»¸öCÁ¬½Ó½»»»Ö¸¶¨·ûºÅextern¡¨C¡¨À´½â¾öÕâ¸öÎÊÌâ¡£ÀýÈ磺
extern¡¡¡¨C¡¨
£û
¡¡¡¡¡¡void¡¡foo£¨int¡¡x£»¡¡int¡¡y£©£»
¡¡¡¡¡¡¡£¡£¡£¡¡//¡¡ÆäËüº¯Êý
¡¡¡¡£ý
»òÕßд³É
extern¡¡¡¨C¡¨
£û
¡¡¡¡¡¡#include¡¡¡¨myheader¡£h¡¨
¡¡¡¡¡¡¡£¡£¡£¡¡//¡¡ÆäËüCÍ·Îļþ
£ý
¡¡¡¡Õâ¾Í¸æËßC£«£«±àÒëÒëÆ÷£¬º¯ÊýfooÊǸöCÁ¬½Ó£¬Ó¦¸Ãµ½¿âÖÐÕÒÃû×Ö_foo¶ø²»ÊÇÕÒ_foo_int_int¡£C£«£«±àÒëÆ÷¿ª·¢ÉÌÒѾ­¶ÔC±ê×¼¿âµÄÍ·Îļþ×÷ÁËextern¡¨C¡¨´¦Àí£¬ËùÒÔÎÒÃÇ¿ÉÒÔÓã£include¡¡Ö±½ÓÒýÓÃÕâЩͷÎļþ¡£

×¢Òâ²¢²»ÊÇÁ½¸öº¯ÊýµÄÃû×ÖÏàͬ¾ÍÄܹ¹³ÉÖØÔØ¡£È«¾Öº¯ÊýºÍÀàµÄ³ÉÔ±º¯ÊýͬÃû²»ËãÖØÔØ£¬ÒòΪº¯ÊýµÄ×÷ÓÃÓò²»Í¬¡£ÀýÈ磺
void¡¡Print£¨¡£¡£¡££©£»¡¡ //¡¡È«¾Öº¯Êý
class¡¡A
£û¡£¡£¡£
void¡¡Print£¨¡£¡£¡££©£» //¡¡³ÉÔ±º¯Êý
£ý
²»ÂÛÁ½¸öPrintº¯ÊýµÄ²ÎÊýÊÇ·ñ²»Í¬£¬Èç¹ûÀàµÄij¸ö³ÉÔ±º¯ÊýÒªµ÷ÓÃÈ«¾Öº¯ÊýPrint£¬ÎªÁËÓë³ÉÔ±º¯ÊýPrintÇø±ð£¬È«¾Öº¯Êý±»µ÷ÓÃʱӦ¼Ó'£º£º'±êÖ¾¡£Èç
£º£ºPrint£¨¡£¡£¡££©£» //¡¡±íʾPrintÊÇÈ«¾Öº¯Êý¶ø·Ç³ÉÔ±º¯Êý

8¡£1¡£3¡¡µ±ÐÄÒþʽÀàÐÍת»»µ¼ÖÂÖØÔØº¯Êý²úÉú¶þÒåÐÔ
ʾÀý8¡­1¡­3ÖУ¬µÚÒ»¸öoutputº¯ÊýµÄ²ÎÊýÊÇintÀàÐÍ£¬µÚ¶þ¸öoutputº¯ÊýµÄ²ÎÊýÊÇfloatÀàÐÍ¡£ÓÉÓÚÊý×Ö±¾ÉíûÓÐÀàÐÍ£¬½«Êý×Öµ±×÷²ÎÊýʱ½«×Ô¶¯½øÐÐÀàÐÍת»»£¨³ÆÎªÒþʽÀàÐÍת»»£©¡£Óï¾äoutput£¨0¡£5£©½«²úÉú±àÒë´íÎó£¬ÒòΪ±àÒëÆ÷²»ÖªµÀ¸Ã½«0¡£5ת»»³Éint»¹ÊÇfloatÀàÐ͵IJÎÊý¡£ÒþʽÀàÐÍת»»ÔÚºÜ¶àµØ·½¿ÉÒÔ¼ò»¯³ÌÐòµÄÊéд£¬µ«ÊÇÒ²¿ÉÄÜÁôÏÂÒþ»¼¡£

#¡¡include¡¡
void¡¡output£¨¡¡int¡¡x£©£» //¡¡º¯ÊýÉùÃ÷
void¡¡output£¨¡¡float¡¡x£©£» //¡¡º¯ÊýÉùÃ÷

void¡¡output£¨¡¡int¡¡x£©
£û
cout¡¡
·µ»ØÄ¿Â¼ ÉÏÒ»Ò³ ÏÂÒ»Ò³ »Øµ½¶¥²¿ ÔÞ£¨0£© ²È£¨0£©
δÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡
ÎÂܰÌáʾ£º ο´Ð¡ËµµÄͬʱ·¢±íÆÀÂÛ£¬Ëµ³ö×Ô¼ºµÄ¿´·¨ºÍÆäËüС»ï°éÃÇ·ÖÏíÒ²²»´íŶ£¡·¢±íÊéÆÀ»¹¿ÉÒÔ»ñµÃ»ý·ÖºÍ¾­Ñé½±Àø£¬ÈÏÕæÐ´Ô­´´ÊéÆÀ ±»²ÉÄÉΪ¾«ÆÀ¿ÉÒÔ»ñµÃ´óÁ¿½ð±Ò¡¢»ý·ÖºÍ¾­Ñé½±ÀøÅ¶£¡