林锐文章-高质量C编程

林锐文章-高质量C编程

ID:83391587

大小:12.27 MB

页数:101页

时间:2023-07-15

上传者:灯火阑珊2019
林锐文章-高质量C编程_第1页
林锐文章-高质量C编程_第2页
林锐文章-高质量C编程_第3页
林锐文章-高质量C编程_第4页
林锐文章-高质量C编程_第5页
林锐文章-高质量C编程_第6页
林锐文章-高质量C编程_第7页
林锐文章-高质量C编程_第8页
林锐文章-高质量C编程_第9页
林锐文章-高质量C编程_第10页
资源描述:

《林锐文章-高质量C编程》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

C++/Cᢣᓭᦻ᝱ᦻ᪗r1₝ᦻ᱐1.0ᦻὅ᪍┦(ᦋᦻᡂ!2001"7ᨴ24

1᱐ᔊ%᱐/᝱ὅ'(ὅ)*!ᜓ,V0.9᪍┦2001-7-1-᪍┦)₝₝ᦻ2001-7-18V1.0᪍┦2001-7-18-ᩋ/012V0.9,ᦻ2001-7-24᪍┦3₝4Ḅ┯7

2891ᦻ᪀.................................................................111.1᱐ᩗ;᱐Ḅ<=..........................................................II1.2ᜮᦻḄ@᪀..............................................................121.3BCᦻḄ@᪀............................................................131.4ᜮᦻḄᵨ..............................................................131.589@᪀...................................................................142Ḅ᱐...............................................................152.1EF.......................................................................152.2GṹF.....................................................................162.3GṹFᑁḄEJ............................................................172.5KFLᑖ..................................................................192.63⛲OḄPQ..............................................................192.8RḄ᱐..................................................................213lj...................................................................................................................................223.1ᐳឋUVlj.....................................................................................................................................223.2WᓫḄWINDOWSYᵨZ[\Uᑣ........................................233.3WᓫḄUNIXYᵨZ[\Uᑣ.............................................254⊤........................................................264.1^_OḄ`ᐜb............................................................264.2cᔠ⊤f................................................................274.3IFgh....................................................................274.4ijghḄᦔ᳛............................................................294.5FORghḄijmᑴo...................................................304.6SWITCH...............................................................................................................................304.7GOTO..........31p5qr335.1stu◤⌕r............................................................335.2CONST(#DEFINEḄxy...................................................335.3rBCUᑣ..............................................................335.4R4Ḅr................................................................346k|”36

36.1'ᦪḄUᑣ................................................................366.3{ᦪᑁ|}~ḄUᑣ.......................................................396.4ᐸ..................................................................406.5ᵨ..................................................................416.6ᵨ(ᢣ┐Ḅxy.........................................................427ᑁᳮ.................................................................447.1ᑁᑖ..............................................................4472/1jfᱫHஹJ•*••**********••***•******************••***************************************************7.3ᢣ┐(ᦪḄx.........................................................457.4ᢣᵪ'/ix᝞⌴ᑁḄ♦♦♦♦.♦.♦.♦.....♦.♦.♦.♦.♦.♦.♦.♦.♦.♦.♦.♦.♦♦477.5FREE;DELETEᢣ┐uᖾ............................................507.6᝱ᑁᔩ................................................507.7¡“£ᢣ┐”............................................................517.8ᨵ¦MALLOC/FREEstu§⌕NEW/DELETE?.................................................................527.9ᑁὑ©uª..........................................................537.10MALLOC/FREEḄᵨ⌕«.................................................547♦11/D/¬JJ®to***************************************************************************************557.12¯°±²³.............................................................568C++ᦪḄᱯឋ......................................................578.1{ᦪ´µḄᭆ·............................................................578.2¸¹.mlJ^08.3'ᦪḄºḕ¼..............................................................638.4^_O´µ................................................................648.5{ᦪᑁὶ..................................................................658.6¯°±²³.............................................................689"Ḅ᪀⌼ᦪஹ᪆᪀ᦪ&'(ᦪ......................................699.1᪀⌼{ᦪ(᪆᪀{ᦪḄ)À.................................................69᝕**********•***************************************************************************************09.3᪀⌼;᪆᪀ḄÂZ.........................................................729.4ÃÄRSTRINGḄ᪀⌼{ᦪ(᪆᪀{ᦪ....................................729.5Å⌕ÆÇÈV᪀⌼{ᦪ(ɼ{ᦪ.........................................739.6ÃÄRSTRINGḄÈV᪀⌼{ᦪ(ɼ{ᦪ...............................739.7ᏕËḄªÌᜐᳮÈV᪀⌼{ᦪ(ɼ{ᦪ...................................759.8᝞ᙠÐÑR4}~RḄÒ{ᦪ.........................................759.9¯°±²³.............................................................7710"Ḅ)*&+ᔠ.........................................................78

410.1ÓÔ......................................................................78p11ÕᐸÖ×...........................................................8211.1ᵨCONSTØ{ᦪḄᏉÚឋ.............................................8211.2ØZḄᦔ᳛...........................................................8411.3¯°ᨵÛḄ...........................................................85'ὃᦻÝ.........................................................................87▬9AC++/CGṹ12⊤......................................................88▬9BC++/Cß⚪.............................................................93▬9CC++/Cß⚪Ḅáᫀ(ãᑖ᪗ä...........................................97

51/A”ᑠsæçᜧéᦪZᕒᢞᙠᘂíîÅçᙠ±íḄïðñ◀¦ᐰ᜜F;õḄö᜜¸÷øù¸úᨬᐜḄüýþçÿ“ᡃ⌼ḄC++/CᨵḄ”ὅ!"#$ஹ#&'()஺+,-./0123▅5678⚓:;!<=>?@6A☢NT/5ὅḄCD஺-ஹEὁGHIGḄJKLMNOPQRᩭTNUᡂWXYZ᠋Ḅ\]ᕒᙠ`Ya᰿cde᧕ghᡂiᱯᓾlmLᡃnoḄpq஺᝞sᙠInternettuvḄ“3w”ḄᕒxyA6᪵Ḅ(1)3wḄᕒ{ᨵ|}⊤ᨵ⚞Ḅᨵ|}⊤3wḄᕒ⚞஺(2)3wḄᕒᑏᵨy;ᵨᡝLḄm஺(3)3wḄᕒ#ᑏṹḄ᝞ᑏᳮᡠᯠ£5஺(4)3wḄᕒ¤u¥¦§Y¨ᦻª«6¬஺(5)3wḄᕒ®ὃG°±G¨0²஺(6)3wḄᕒᑏᦻ᫏£◤⌕ᦻ᫏ᨵ¶Ḅ·¸ᵨᦻ᫏஺(7)3wḄᕒ2iLᵨᡝ¹ºᵨᡝ◤⌕»஺(8)3wḄᕒ¼`½¾¿gḄᳮÀ◀ÂÃLAᜮᜮ஺(9)3wḄᕒḄᙠÅ-&UwÆÇÈÉAÃÊËÌÍḼPᘤ|ÈЫ/3001ḄÑÒᦋ┯஺(10)3wḄᕒᙠtᓤ9:00ᑮ×ᓤ5:00cØÙ᝞!ᑮÃᙠtᓤ9:00Ù6⊤ÃM᧤Û-Ü«ᑮÝᙠ஺ᐹᜓtàᱯáââãäåæIçèὁ஺ᡠ᜻êᕒḄëìíᯠîïðìᩭñò஺Uóᙠôõ0yö÷øᩭøùஹ`úûüýìþÿḄᨬ஺ᡃ᪵᜽ᡂ᪵Ḅ“”Ḅᕒ"#$ᨵ&ᑮ()*஺ᡃ+,ᜧ.ᑮ/012ᓝ4ᩭ6789(.:;<ᑏ>ᦪᓝ@AC++/CBṹ஺ᨵ᪵ḄDEFGEᡃHIJ&KL<ὁ>ᔳOᡃPQḄRSTUVẆXᐵ([ᡂᵯ]CADF3D^_.⚞a)cdᦪ@A,ᢈghᩖjk⚟஺mRS⚣⚣oᝄᨵ6qRSo&✌stuᜧ.vᵯᾯᜧxR

6Sz{6|ᝄ஺ᙠ19954PQḄ6ᝅ^_RSᑮ20004ᨵ஺ᑡm“2”ᡃ&KL<>ᔳOq|஺,/ᡃᵨ64PQ>6q10@AC++BṹḄ3D^_RSᡃᑁ&⊤☢ᙢᔣ6£ḄRS¤ᦟ஺¦§ᯠ+©ª«¬3D^_⚞aᓾᙠ®ᓝᑖ°ᑁᢣIRS²ᜐ´ᜧµ;┯·஺¸ᝅRSLᵨ¹ºḄ»¼⊟¾¿6)ᣵ6ᙽᡙ6)ẚqÄ஺ᡃÅÆÇᕆᙢÉᑮᝅRSÊËᵨÌÍ64Ḅ⊈Ïᓄ>ÑÒ>ḄRSÓÔ஺ḄÕÖ×ØQvᙠᨬÙḄÚᙠÛÜFÙÝÞᡃß>àÚáḕ“☢ã”ä4´åæçRSµ;ḄèẠêÉ஺⊡ì''ᑁî"ÝÞð&Ὺòó>ôᩭ஺/012õä4ᡃᑮöRtuẆ÷▾ùúßûüöRÓÔ6£ýàRSúþḄ☢ÿ஺ᡃᑏᦪstrcpyḄṹ஺᧕ᔳ┯Ḅᦪ☢ὃ1!"#$%2&┯ᜐᳮ%)3*+,ᩖ.ᑖ᪆)ᵨ234ឋ67஺ᙠᜧ:;ᩭ=ᨵ?᝞AB$ᙢὃDᡃḄ"E஺ᡃᓄGHIᦋᦪKLMNOᡃPQRR᳾T஺ᡃUVᢘXᙢY“ὃ[”ᜧ]^_ᙢ&“ὃ[”஺“4`”abcde஺ᡃfRRᙢgḕK஺ᡃigḕjḄkblmᑏᡂᦻpqᙠrst▅vwxyz{|?ᕒḄᐳ஺ᡃAᨵᜧIT᝞ஹsஹᐶḄ஺ᜧQ34᳛yz¡"⌕£¤Ḅ᪶k¦⚪஺4"E¨©ª«¬⌕Ḅ⁚¯°yz☠!"ᩭ²³Ḅ஺ᡃk´Ḅὁ`4`6ᔲ!ᑏ&4Ḅ"Eᩭ·b¸6¹ᡃḄºᔊ▅ᔊᩭ¼ᑁᜧ:Ḅ©*¾ᦟÀÁ᪷¹=ᨵÃÄ4"E¨©ḄÅÆᦟÇ:cÈxÉÊᐵkyzḄ஺ÌÍR:Ḅ"EᕒÎÏᙠÐḄ"EᚮÒÓᔛMÕᜮ×jØᨵÙkblmÎY᩽᠒ᡃ¹Ü஺³ᙠᑁITÝᨵ:ÞஹắÞஹàÞᦻáḄyz{|?ᕒââḆäᙠåæᜧ:ᦟÀH¹“ᐜᜩé”ê6ᑮ¹ìᯠ²³Ḅîï஺ð¦ᨵñxyz{|?ᕒòóôឋஹᏉöឋஹ÷☠ឋஹᦔ᳛ஹ᧕ᵨឋஹ÷ùឋ)÷ᳮ£ឋ7ஹ÷᡽ûឋஹ÷,ᵨឋஹüឋஹ÷ýþឋÿឋ᝞ᢣᙠᵨ᝞஺“”Ḅ!

7ᡃ$ᨵᐙᑖḄᳮ)ᶧ⇋,1-.ὁ0123ᵨ◚5┯7Ḅ89-.:;<ᡂᯠ?@ABCDEFGHIJḄ!2-.0KᙠLM⚞OᑏQ᩽ᨵSTḄUṹ@WXYZᐰ\]^_`Ḅ88☢☢஺bcd᝞e஺ᡃᑮghijklMmᩭ@▮p☢qᡈsqtuvw“x”“ὁ”.yᕒḄ-.ᢈ@ᔠ}᳛ᜧ10%஺ᨵᑏQᐰᔠ⌕Ḅif@.yᕒᢣ┐ஹᑁᳮM.......⚞$ᦢGHJḄ஺ᡃtq,ᨵMx14wắ¡¢@ᙠ£¤¥1¦§¨$©“C++/C-.ᢈ”᥎«ὃq஺ᡃᜧ®q⚪°°ᡠᨵḄE²³°஺´µ¶ᨵM·¸}@ᨵᦪº»ᑖ஺¼½0¾¿ḄÀÁ$Âtq@Ã᪵MÅÆᙢ஺JḄᡃ“È0É”ᡈὅ⌕t@Ë_`£AᕒÌḄ⌕஺⌕⍝ÎÏஹghijஹᐶѾ¿ḄᕒkÒᙠÓᑁITÔÕÖקᑡḄ@᎚Ú¨$Ḅ-.E᝞eÛḄÜ@ᡃ$ÝÞᦢ3ß¾¿àQḄ_`ᕖâ.yE-ã@äåæÞçᐶèé_`êÕ@ëìí஺ᡃᡭïðñ-.ὁ0ò-.0@óôõö÷஺ðñ123øðᙢ-ᑏQ.yḄ.yᕒùÏ-.ὁ0஺ðñ223øðᙢ-ᑏQ°úஹ.yḄ.yᕒùÏ-.0஺᪷ügýðñ@þgºᑮÿᡃὁ஺ᙠᑏᡃ▅☢Ḅᦻ℉#$%$&'஺()*+,-./01ᢈ3453ᐰ☢78⚔:;<=>?@ABCDEὁF஺GHFᡃ᪵ᙠJᑁLMLNḄᕒPQR3STᑮ1V┯XᦋZ2[\]ᦑ_V`;3bᢝdeᜩᜩᔣ஺

8;ஹ1j✌ᐜmT▬oBḄC++/Ct⚪v⌕%xᫀzὃ|,-Ḅ/}~᝞஺ᯠ᯿xᫀᡭᑖ஺v1z᝞ᓝᑖm⌕⌕஺/}~ᵫe⌼ᡂḄḄ¡¢ஹ3¢£ᨵ:ᜧᐵ§?ᨵ¨©ᦗḄ஺ᡂ«$©¬®Ḅ¯°X$ᜧ±JXᙠ²±³´*µ¶1·¸J¹ᔩ»⌕3¼½¾ᦋᣵḄ/eÀ;ÁὃtX3Â஺v2z᝞ὃÂ⊤ÅḄᢈÆ0Ạ┯GH3ȾdeஹÉ®஺᝞?£ᨵÊᑮᔠ〉ḄÍ#ᓫÏÐᑮÑÒÓtt஺v3z᝞ὃÕ85ᑖ¬Ḅ@ᡂ«ᨵ¸ØF¶)ᡠᙠḄÚÛ#“C++/C/”Þß஺GH3FᡃR::à<ஹáâã஺äåᡃæ[*+⚩@èéXêë᢬ᑮᡃRíîᩭ஺v4z᝞ᙠ£ᨵñòóḄôõ¼ὃöᑖGH3ᦈᡃTḄøù஺/ὃtúûm▅1Ḅüᦻ஺1ÀýþÀÿ⌕C++/C஺⁚஺⌕!"#$$%%&'஺()*ᙠᨬ-Ḅ/ᑗ1◤345஺6789:;•=᝞?ᑴ5ᜧBCDḄEFᡠᨵIᕒK⌕⍳M஺᝞?NὅPQRSḄᔠUḄVWEFXᵨZ⌕[&஺\ᙠ]᎛_`9abᑏde₝᝞?ᦋhiᨵj៎Ḅ]᎛஺lm᪵⍝ᳮ஺qrsqᓝ/u⚪ᢈxS]⌕y᩽{ὃ஺ᱯqr“ᑁ*ᳮ”N⊤⊤hᵨ஺ᨵ/mqrjPQ''ᢣ┐”ᑏQ┯ᡃᑗ/஺Dᕜᡃᜩ/Bug,¤ᑮ¦“ᢣ┐”§⚪[-¨Nqr஺ᐝRSªᨵ▲Ḅ¬ᜧB▅NRSḄ¯ὃᦻ±E#K²ᐺ´℉஺᝞?UḄ¶²ᐵ⌕¸¹º஺᝞?U¤ᡂ¼½¾Ḅ¿À89\ᕒ¬U▅Nᢥ᯿CMMIÅ&ÇÈÉḄÊᔠËÌ)ᓣ/Î▤஺)ÐÑÒḄᕒVDÓᔣÕÖ×ᵨØÙ¿ÀVẆ;IÛÜCMMIᨵᐵÝᧇᨬ-¯ßàá஺

9ஹ᱐ᩗRSḄᜧÙᑖᑁäÜᩞæWὅ/çèḄSéêëìíî᱐ðñ᦮ᳮóᡂ¼)ÐÑÒÕÖ×ᵨØÙḄÅᓄᦻÀm]W¼àáᦟᩞ஺ᵫæC++/C÷ᡠᕜøḄᢈxùᨵúûDü஺Ḅ-²ý×þᜧBᐳᡃᩭḄ஺ὅḄᵯᦻ᫏஺᱐ᩗ᝞!1#$ὅ%&'()ஹ+ᦋḄᑁ./0%&1ᦋὅ2ᡠ4ᓫ6஺!2#89ὅ:%0;<᱐ᡈᜧ?ᓺA஺!3#᝞CDEFGHḄᕒJ;ᑮLMNᵨ&PAQRS஺⚜Uᑮ2002W7ᨴᡃZ[\ᑗᔠ_``aḄCMMI3fghiᫀ஺klᒹnᙠᑁḄp1000⚓rZtuvw஺xy$ὅFz<ᢇ|[}஺᪍┦2001W7ᨴ

101ᦻ᪀C++/Cᑖᦻ஺ᦻᵨḄ(declaration),ᜮᦻ஺ᦻᵨḄ(implementation),(definition)ᦻ஺C++/CḄᜮᦻ&“.h”CḄᦻ&“.c”C++Ḅᦻ&“.cpp”(ᨵ&“.cc”ᡈ“.cxx”)஺1.1᱐ᩗ¢᱐Ḅ᱐ᩗ¢᱐Ḅ6ᜮᦻ¢ᦻḄᜮ(£¤¥¦1-1),§⌕ᑁ.ᨵ:(1)᱐ᩗª«஺(2)ᦻ¬᪗®¯᤺⌕஺(3)±²᱐³ὅ/+ᦋὅµᡂ·¸஺(4)᱐ᔊºª«஺/**Copyright(c)2001,ÆÇ)Èᨵ▲HÊËÌᵨÍÎÏ*Allrightsreserved.**ᦻ¬fi1ename,h*ᦻ᪗®ᳮᑜ*᤺⌕⌕ᦻḄᑁ**±²᱐1.1*ὅᐭ"ὅ(ᡈ%ᦋὅ)()*µᡂ·¸2001,7ᨴ20/**×Ø᱐1.0*Ùὅᐭ0"ὅ(ᡈ%ᦋὅ)()*µᡂ·¸2001,5ᨴ10/*/¥¦1T᱐ᩗ¢᱐Ḅ

111.2ᜮᦻḄ᪀ᜮᦻᵫÛÏᑖᑁ.Üᡂ(1)ᜮᦻᜮᜐḄ᱐ᩗ¢᱐(£¤¥¦1-1)஺(2)⚜ᜐᳮᙽ஺(3)áᦪ¢ã᪀ä஺Ꮇæᜮᦻ¬graphics,h,ᜮᦻḄ᪀£¤¥¦1-2஺ூrᑣ121௃ë■íᜮᦻîïðñᵨ̱ᵨifndef/define/endif᪀ôQ⚜ᜐᳮᙽ஺ூrᑣ1-2-2௃ᵨ#includeuúᩭñᵨ᪗ûüḄᜮᦻ(ýþᘤ᪗)஺•ூᑣ1-2-31ᵨttinclude“filename.!!”"#ᩭ%ᵨ&᪗Ḅᜮᦻ*(,-ᘤᵨᡝḄ01)஺2ூ341-2-11ᜮᦻ*5678“9:”;<78“=>”ᙠC++BC5DEḄᡂᕒHᦪJKᙠ9:ḄLMN=>DOPQRᡂSᑁὶHᦪ஺VWᯠYZᩭ[ᑏ]Ḅ^_D`ᓾ⌼ᡂcd"k9:ᑖD//%ᵨ᪗Ḅᜮᦻ*#include“myheader.h"//%ᵨ&᪗Ḅᜮᦻ*voidFunctionl(••,);//ᐰxHᦪ9:classBox//Eª᪀9:()¬#endif1-2C++/Cᜮᦻ*Ḅª᪀

121.3=>ᦻ*Ḅª᪀=>ᦻ*ᨵ®ᑖᑁ¯°(1)=>ᦻ*ᜮᜐḄ᱐ᩗ᱐9:(±1-1)஺(2)²e³ᜮᦻ*Ḅ%ᵨ஺(3)´µḄ¶~o(ᒹ¸ᦪ¹ºṹ)஺Ꮇ½=>ᦻ*Ḅ¾¿Sgraphics,cpp,=>ᦻ*Ḅª᪀±1-3஺//᱐ᩗ᱐9:1-1,ᜐḕᶍ஺#include“graphics.h"//%ᵨᜮᦻ*//ᐰxHᦪḄ¶~ovoidFunctionl(•,,)//EᡂᕒHᦪḄ¶~ovoidBox::Draw(…)1-3C++/C=>ᦻ*Ḅª᪀1.4ᜮᦻ*Ḅ1ᵨÀÁḄ,´BÂ᝞Basic.FortranÄᨵᜮᦻ*ḄᭆÆDC++/CBÂḄÇÈὅWᯠYᵨvᵨᜮᦻ*D`ÊÊ<:ᐸᳮ஺VͲᜮᦻ*Ḅ1ᵨᶍ1ÎÏ°(1)ÐÑᜮᦻ*ᩭÒᵨÓÔ஺ᙠÕqÖᔠDغṹ<_(ᡈ<)ᔣᵨᡝÛÜD6⌕ᔣᵨᡝtÝᜮᦻ*ÞßᑴḄᓽJ஺ᵨᡝ6◤⌕ᢥ᯿ᜮᦻ*5Ḅåæ9:ᩭÒᵨÓÔD;<çᐵéåæêr¶~Ḅ஺,-ᘤY5tëìíḄºṹ஺(2)ᜮᦻ*ÔîïEðñᐰòó஺᝞ôõöåæN¶~ᡈNvᵨ÷Dᐸ^#kᜮᦻ*5Ḅ9:

131.5᪀᝞Ḅᜮᦻᦪ᝞ᓝ!"#ᜮᦻ$%&ᦻᑖ()*+,-Ḅ./0+12஺3᝞4#ᜮᦻ)*+include.#%&ᦻ)*+source.4/56.஺᝞78ᜮᦻ59ᨵḄ;,<=ᵨᡝḄ@ABᵨᑣDᨵE⌕GHᐸ“KL”஺NOPQRS◚UV89ᨵḄᜮᦻ4/$%&ᦻ*W+-.஺

14X2YḄ᱐[᱐[\ᯠ,<^_Ḅ`ab<^_4cឋ஺Ḅ᱐[efgᨎஹij5klḄm⌕᪀ᡂpq஺4/rḄ᱐[sN“tu”஺vḄ“tu”4wxyOᯠz{ᐶ}~~஺Ḅ“tu”᝞≏wxz{ᯠᕡ12ὅᨵP஺ᕒḄ“tu”⊡ᜧᦟḄᙠᨵE⌕஺2.1Ḽᑖ◞¡¢Ḅ£ᵨ஺{¤(,¦,§)#©Ḅª«Pgᨎ஺,<¬ᑁ*\ᯠᡭᓺ±ᨵḄ5<²ὑ8´µb5¶{஺ᡠ/,⌕¸,{ᵨ஺•ூ»ᑣ2-1-11ᙠ¼½KL¾¿ஹ¼Àᦪ%&Á¾¿Ã⌕P஺ÄÅÆ32-1(a)•ூ»ᑣ2-1-21ᙠÀᦪ¤ᑁÇÈÉÊᑗÌᐵḄÎϾÐ,Pᐸ;ᙢÒ"Pᑖ◞஺ÄÅÆ32-1(b)////voidFunctionl(••,)while(condition)({statement1;)////if(condition)voidFunction2(••,){(statement2;J}else//{voidFunctions(•,,)statementsë()//)statement4;}Æ32-l(a)Àᦪ¾ÐḄÆ32-l(b)ÀᦪᑁíḄ

152.2îṹ•ூ»ᑣ2-2-11îṹðñòó᝞ð%&ôõᡈðᑏᩩÎÏ஺V᪵Ḅîṹú᧕▅cýþÒ0+ᑏÿ஺•ூᑣ2-2-2௃ifஹforஹwhile,doᓰ᡻ᐸ஺᡻ᨵ⌕஺!᪵#$■&'ᑏᜫ*஺+,2-2(a)-./01Ḅ3ṹ+,2-2(b)-./0Ḅ3ṹ஺intwidth;//CDintwidth,height,depth;//CDGDIDintheight;//GDintdepth;//IDx=a+b;X=a+b;y=c+d;z=e+f;y=c+d;z=e+f;if(width

162.33ṹᑁḄ[/•ூᑣ2-3-1௃ᐵ⌕ᶇ[/஺constஹvirtualஹinlineஹcaseᐵ⌕ᶇ[/ᔲᑣ᪆ᐵ஺ifஹforஹwhileᐵᶇ-•[/'('$¢£ᐵ஺•ூᑣ2-3-2௃¤ᦪ¦⌕ᶇ[/'('$§ᐵ¨©஺•ூᑣ2-3-31'('ᔣᔣ«ᜐᶇ[/஺•ூᑣ2-3-41‘’⌕ᶇ[/᝞Function^,y,z)஺᝞p'®’¯Ḅ°±²ᐸ⌕ᶇ[/᝞for(initialization;condition;update)»•ூᑣ2-3-51³´µ¶²ஹwxµ¶²ஹ·¸µ¶²ஹ¹ºµ¶²ஹ»¼µ¶²᝞“="ஹ“+=”“II"ஹÀᐗµ¶²Ḅ«Â[/஺•ூÃIÄ2-3-61ᐗµ¶²᝞“”ஹ(ᙢᙬÇ·²)«[/஺•ூᑣ2-3-71!ȵ¶²«[/஺\ூ]^2-3-1௃ÉÊ⊤ÌÍwxÎḄfortif-ÏÐÑ#$〉ÂᙢÓᣵÕ[/᝞for(i=0;i<10;i++)tif((av=b)&&(cv=d))voidFund(intx,inty,intz);//01Ḅ./voidFund(intx,inty,intz);//0Ḅ./if(year>=2000)//01Ḅ./if(year>=2000)//0Ḅ./if((a>=b)&&(c<=d))//01Ḅ./if(a>=b&&c<=d)//0Ḅ./for(i=0;i<10;i++)//01Ḅ./for(i=0;i<10;i++)//0Ḅ./for(i=0;I<10;i++)//ÖḄ[/x=aFunction();//⌕ᑏᡂb->Function();+,2-33ṹᑁḄ[/

172.4ÉØ•ூᑣ2-4-1௃ḄᑖÚ²'{'t'}'ÝᓰÞ»Êf,ᑡfg§qᵨàáḄÉØ஺•ூᑣ2-4-2]{}ᑁḄ3ṹᙽᙠ'{'ãäᦪ/ᜐÉØ஺+,2-4(a)-./01ḄÉØ+,2-4(b)-./0ḄÉØ஺voidFunction(intx)voidFunction(intx){(…//programcode…//programcode)}if(condition)if(condition){(…//programcode…//programcode}}else{else…//programcode()…//programcode}for(initialization;condition;update)for(initialization;condition;update){r…//programcode…//programcode))While(condition)while(condition){(…//programcode…//programcode)}᝞p£åæᝅḄ{},ᑣèᵨéêÉØ᝞ë|()}+,2-4(a)!"#$ḄÉØ+,2-4(b)!"%#ḄÉØ

182.5Îíᑖ•ூᑣ2-5-1௃3ṹᨬᜧÎDðñᑴᙠ7080²$ᑁ஺3ṹ⌕ÖÎᔲᑣóôõÖᩭ÷øÊᡭᓺ஺•ூᑣ2-5-21Î⊤ÌÍ⌕ᙠûüᐜþµ¶²ᜐíᑖᡂÿᙠ✌()஺ᑖḄ⌕〉Ḅ᣸᱐᦮!஺if((verylongervariablel>=verylongervariableফ&&(very_longer_variable3<=very_longer_variablel4)&&(verylongervariables<=verylongervariablel6))(dosomething();virtualCMatrixCMultiplyMatrix(CMatrixleftMatrix,CMatrixrightMatrix);for(verylongerinitialization;very_longer_condition;very_longer_update)(dosomething();J"#2-5$Ḅᑖ2.6%⛲Ḅ'(%⛲**&,-☠/ᦪ12345-☠/67859ᨵ;<Ḅ=⚪஺?@%⛲*☠/ᦪ123#᝞Bint*X+CDEFGᑏIJKLMᓽx5int23Ḅᢣ┐஺EQᑏIḄRS5T᧕VWXY#᝞Bint*x,y;GᜐyT᧕[XY\ᢣ┐67஺]ᯠ@x*yᑖ_D`aXYbcd5eefghi᪵k஺•ூoᑣ2-6-1௃,@%⛲**&r☠678#᝞Bchar*name;int*x,y;//Gᜐydt[XY\ᢣ┐

192.7uvcwḄuv\"/*_*/ஹC++w{|}ᙽḄuvᵨ"/*…*/"uvᵨuvᵨB1᱐ஹ᱐ᩗ2ᦪ3⌕Ḅṹᡈ"஺]ᯠuvᨵᳮYṹbuhdᙢᵨuv஺"#2-6஺•ூoᑣ2-7-11uv5ṹḄ“"”£d5ᦻ᫏஺|}{Ḅuvd¦§¨©uvª«t¬e®¯°஺uvḄ®᪵⌕±஺•ூoᑣ2-7-2௃᝞²ṹᩭ´5µ¶Ḅᑣd·¸uv஺ᔲᑣGº»e¼½஺#᝞i++;஻i¸1,¾Ḅuv•ூoᑣ2-7-3௃¿ᑏṹ¿uv%ᦋṹÁÂ%ᦋÃ,ḄuvÄÅuvÆṹḄÇឋ஺dÉᨵᵨḄuv⌕ᑤ◀஺•ூoᑣ2-7-41uv,ÌÍஹ᧕Î■ÐuvᨵÑDឋ஺┯XḄuvdbÓÔÕ£ᨵÖ஺•ூoᑣ2-7-51×7`aᙠuv{ᵨᑏᱯÙ5dᵨᑏ஺•ூoᑣ2-7-61uvḄ'(,Æ[ÚQḄṹÃÛᙠṹḄEÜᡈÝÜdᙠÞÜ஺•ூoᑣ2-7-8௃ṹJK$ᱯÙ5ᨵßᝅÂ,ᙠáḄâãᜐ¸uv▅!஺/*if(…)*ᦪåæB(*çᐭᦪB*çᦪBwhile(...)*éêëB(*/voidFunction(floatx,floaty,floatz)}//endofwhile{}//endofif)"#2-6|}Ḅuv

202.8&Ḅ᱐(2@ᦪ1*ᦪìíᙠWᐸ{ᦪ⊤"«2Ḅ\(ᡈðñò)஺2óᐵõöpublicஹprotected*private,ᑖÙᵨ÷áᦪ1*ᦪ5øᨵḄஹùÄúḄᡈὅ5üᨵḄ஺i᪵ýᑮÿ◚ḄḄᓽ⌕᜜⍝Ḅᑁ◚ᐸᑗᑁ஺ᡃᵨḄ"#$%⌕&'ᡂ)┡+,-./01ᡮ஺Ḅ᱐45⌕ᨵ7894:(1);private<Ḅᦪ>ᑏᙠA☢;public<ḄCᦪᑏᙠD☢᝞FG8-3(a)஺HᵨI8᱐4ḄJKᕒ5MḄNO“ᦪ>QRS”UVᐵXḄᑁYZ᪀஺(2);public<ḄCᦪᑏᙠA☢;private<Ḅᦪ>ᑏᙠD☢᝞FG8.3(b)HᵨI8᱐4ḄJKᕒ5MḄNO“\QQRS”UVᐵXḄ]^_`a+,᪵Ḅcd(ᡈgh)஺jkC++ᦟmnoᑮBiarneStroustrupqr℉tḄuvwᙢHᵨy“ᦪ>QRS”Ḅnᑏ94{|}ᨵk~⍝ᳮ஺ᡃὅHᵨ“\QQRS”Ḅnᑏ94ᓽ✌ᐜὃ⇋^_`a+,᪵ḄCᦪ஺I]jkḄ“I᪵ᙠNOᨎ9▅஺QᵨᡝᨬᐵSḄ]cdᐜᑮᚮᨵᦪ>ᡂᕒ”classAclassA((private:public:inti,j;voidFund(void);floatx,y;voidEunc2(void);public:private:voidFund(void);inti,j;voidFunc2(void);floatx,y;}}FG8.3(a)ᦪ>QRS᱐4FG8.3(b)\QQRSḄ᱐4

21q3¡¢£¤ᑣ¦§℉£Ḅ¢£¤ᑣ'¨Microsoft©Ḅ“ᒼᱛᑭ”_¢£¤ᑣḄ5⌕®]“ᙠ¯°±Cᦪ£R²ᐭA´µ¶·JKḄᳮ¸”஺G᝞ᡠᨵḄº»¯°ᙳchQA´½]ᢣ┐¯°ᑣÀ²A´P஺᝞Á¯°ᵫppchᜮᑣ⊤Æ]ᢣᔣº»ᢣ┐Ḅᢣ┐஺“ᒼᱛᑭ”ᨬᜧḄÉV]ÊᳲG᝞inti,j,k;floatx,y,z;᎚½Hᵨ“ᒼᱛᑭ”¢£¤ᑣᑣ^'ᑏᡂintil,ij,ik;//A´i⊤FintὃÓÔᨵ8¢£¤ᑣᡠᨵḄJKᕒÕÖJKNOᦟ×nØ/ᢣÙ¢£¤ᑣ஺¢£¤ᑣ·ÚÛÜÝÞ{]“ᡂßàᐵ”Ḅáᡃ⌕ᓄãkäåæçèÆéêᨬëḄ¢£¤ᑣ^'ᑴÙ8íᜧkᦪ⚗ᡂᕒïḄ¢£¤ᑣ{ᙠ⚗Rðñòó஺3.1ᐳឋ¤ᑣr⁚÷øḄᐳឋ¤ᑣ]ùᜧkᦪJKᕒHúḄᡃ^'ᙠ⍳üIýᐳឋ¤ᑣḄA`þÿ᡽ᐙᱯḄᑣ᝞3.2⁚஺•ூᑣ3-1-1௃᪗ᦻ!"“$ṹ”஺᪗ᨬ()ᵨ+ᦻᓫ-ᡈᐸ0ᔠ23456▅஺ᑗ9:ᵨ;<=ᩭ?@஺ABCḄ+ᦻᓫ-DEFGHᩖᵨ-JK஺L᝞⌕NCurrentvalueᑏᡂNowValue஺•ூᑣ3-1-2௃᪗ḄQRᔠ^min-length&&max-information”Sᑣ஺TᓝVWὁANSIC@YJZ[6\Y]^ḄC++/C_ᨵa▲ᑴ஺DEᩭdQ@Yef(ᙢ⊤ijkᡠmᦪ@ஹpq@ஹr@QiᓝT\Ystu஺vw@YxᔲzQ{(|}~L᝞pq@maxvalmaxValueUntilOverflow(ᵨ஺ᓫYḄ@YxᨵᵨḄ}Ḅ᝞,11,3*,2ᵨmᦪᑁḄpq஺•ூᑣ3-1-3?@ᑣqᡠ)ᵨḄᡈᐹḄᢝD஺L᝞WindowsᵨABḄ᪗)ᵨ“ᜧᑏ”¡᣸Ḅ£¤᝞AddChild஺¥UnixᵨABḄ᪗)ᵨ“ᑏ¦§ᑜ©”Ḅ£¤᝞add_child஺ªN«¬r

22¡ᙠD®ᵨ஺•ூᑣ3-1-4௃ABC⌕¯]°☠ᜧᑏ²ᑖḄ´µḄ᪗஺L᝞¶intx,X;஻pqxX¸᧕¡ºvoidf00(intx);//mᦪfooFOO¸᧕¡ºvoidFOO(floatx);•ூᑣ3-1-5௃ABC⌕¯]᪗¼ᐰ´¾Ḅpq6ᐰpq¿¬ὅḄᵨÁ¾¥FÂ<Ã┯ÅÆF:ÇÅ$஺•ூᑣ3-1-61pqḄ@Y:ᵨ“@-”ᡈὅ“ȸ-+@-:L᝞¶floatvalue;floatoldValue;floatnewValue;•ூᑣ3-1-71ᐰmᦪḄ@Y:ᵨ“Ë-”ᡈὅ“Ë-+@-”(ËÍ-0)஺rḄᡂᕒmᦪÐ:ᵨ“Ë-”ÑḕᶍᣵḄ@-xÕÖ×Ø஺L᝞¶DrawBox();//ᐰmᦪbox->Draw();//rḄᡂᕒmᦪ•ூᑣ3-1-81ᵨÙKḄÚk-0?@ᐹᨵÛÜkḄpqᡈ´ÚËḄmᦪ஺L᝞¶intminValue;intmaxValue;intSetValue(...);intGetValue(...);ÝூÞß3-1-1௃qàá@YC¯]ᦪYâã᝞Valuel,Value2◀åæçèḄK◤⌕âã஺«xtê■ìABᕒᏕîït?@Ëᾯñ¥òóÂôkḄ@Y(õtᵨᦪYâãᨬḕö)஺3.2÷ᓫḄWindowsᵨAB?@ᑣὅÕ“ᒼᱛᑭ”?@ᑣûêᔠᳮḄ÷ᓄ§þḄ?@ᑣ÷ᓫ᧕ᵨÿ〉ᔠWindowsᵨḄ஺

23•ூᑣ3-2-1௃ᦪᵨᜧᑏᜮḄᓫᔠᡂ஺᝞"classNode;//classLeafNode;//voidDraw(void);//ᦪvoidSetValue(intvalue);//ᦪ•ூᑣ3-2-21;<=ᦪᵨ>ᑏᜮḄᓫᔠᡂ஺᝞"BOOLflag;intdrawMode;•ூᑣ3-2-3௃C<ᐰᵨᜧᑏḄEᵨFᑜHᑖᒘᓫ஺᝞"constintMAX=100;constintMAX_LENGTH=100;•ூᑣI3-2-41☟᝱;

24•ூᑣ3-2-7tu■wxyz{Ḅy|᪗~ᐸz{ḄEhitᔜ᪗~W᧜ឋḄXY஺᝞᪗OpenGLḄᡠᨵzᦪᙳiglᜮEᡠᨵC<ᡈᙳiGLᜮ஺3.3ᓫḄUnixᵨᑣ

254⊤¡¢£¤¥¦ὅhᝰᶧ"ªifஹforஹwhileஹgoto,switchf᪵ᓫḄ¬®⌕¯°±²³E´]´>⚪ᜧ¶·ᡃ¹Ḅº»¼ᕒᵨ◚¾┯ÀḄÁ¡ᑏ⊤¡¢£¤¥EᡃÂîÄÅÆḄ┯À஺⊤¡¤¥ÇÈC++/CḄɤÊ᪀¤Ì஺ÍÎÆᓫ.EÐcᵨÑ◚ÒÓÔ¼஺£ÕÖu×Øcᵨ⊤¡¤¥Ḅy|ᑣlÙÚ஺4.1ÛÜḄÝᐜßC++/C¤àḄÛÜᨵᦪᓝâEÛÜḄÝᐜßlÊᔠã᝞⊤4-1ᡠ[஺äåyᐗÛÜ+-*ḄÝᐜßêëḄìᐗÛÜ஺ÝᐜßÛÜÊᔠã()[]>.íîïð!~++--(ñ)sizeofCDEFí+-*&//%íîïðê+-íîïð«»íîïðᑮ<<=>>=íîïð|===íîïðó&íîïðAíîïð᣸1íîïð&&íîïðᑡIICDEF?"CDEF=+="=*=/=%=&=A=íîïð1=«=»=⊤4-1ÛÜḄÝᐜßlÊᔠã•ூᑣ4-1-1௃᝞LMṹOPḄQRSTUVWᵨ÷øØ⊤¡ḄùúûEjkcᵨüýḄÝᐜß஺ᵫÿ⊤4-1Ḅ■ឋᵨ⊤Ḅ!"#$஺&᝞(word=(high«8)Ilow

26if((aIb)&&(a&c))4.2*ᔠ⊤᝞a=b=c=O,᪵Ḅ⊤.*ᔠ⊤஺ᐕ0*ᔠ⊤1ᙠḄᳮᵫ((1)6ᑏ89:(2);<=ᦔ᳛஺@⌕■Bᵨ*ᔠ⊤஺•ூEᑣ4-2-1௃H⌕<ᑏI*ᩖḄ*ᔠ⊤஺&᝞(i=a>=b&&c

27if(!flag)//⊤kflagᎷᐸ¥Ḅᵨ¯°MH±²³&᝞(if(flag==TRUE)if(flag==1)if(flag==FALSE)if(flag==0)4.3.2᦮aT•ூEÀIÁ4-3-21᦮ᵨ“=="ᡈ“Ã=”a0஺Ꮇ¢᦮Ḅ£¤value,¥aTḄ᪗¡if\]᝞¦(if(value==0)if(value!=0)HÈÉḄ²³jᑏᡂif(value)//ÊËn|pvalueif(!value)4.3.3ÌÍaT•ூEÀII4-3-31HÌÍᵨ“=="ᡈ"Ã=”aᦪ¤஺ᓟÏ⌕ᶇÑÒfloatÓdoubleḄᨵÔÕ▲ᑴ஺ᡠ;⌕ÙÚÌÍᵨ“=="ᡈ“Ã=”aᦪ¤Q¢¯Ûᓄᡂ“>="ᡈ"<="ß஺Ꮇ¢ÌÍḄ£¤x,if(x==0.0)஻◚z┯|ḄÛᓄif((x>=-EPSIN0N)&&(x<=EPSIN0N))ᐸ`EPSIN0Nᐕ0Ḅ|è(ᓽÔÕ)஺4.3.4ᢣ┐aT•ூEÀIJ4-3-41ᢣ┐ᵨ“=="ᡈ"Ã=”aNULL஺ᢣ┐ḄT“í”(NULL),îïNULLḄTa0ðñ@XὅÑHñ஺Ꮇ¢ᢣ┐Ḅ£¤P¥aTḄ᪗¡if\]᝞¦(if(p==NULL)//paNULLóôõpᢣ┐if(p!=NULL)H⌕ᑏᡂif(P==0)//ö᧕Ën|pp᦮if(p!=0)ᡈὅif(P)//ö᧕Ën|pPif(!p)4.3.5øif\]Ḅ⊡ᐙûü

28ᨵý᎛ᡃᑮif(NULL==p)᪵Ḅ஺ᑏ┯ᕒ!■#$if(p==NULL)%ᑏᡂif(p=NULL),(ᨵ*+p,NULL-᎔஺/0ᘤ2!if(p=NULL)ᔠ4Ḅ5ᢣ7if(NULL=p)┯%Ḅ8!NULL9:;஺<ᨵ=⍗ᑮif/else/returnḄGᔠHI$᝞KLMḄif(condition)returnx;returny;ᦋᑏ!if(condition)(returnx;}else(returny;)ᡈὅᦋᑏᡂXYZ[Ḅreturn(condition?x:y);4.4^_`aḄᦔ᳛C++/C^_`a<for`afᵨ⚣᳛ᨬjwhile`aᐸndo`aopᵨ஺q⁚stuv^_wḄᦔ᳛஺xj^_wᦔ᳛Ḅyqz4{|^_wḄ}ᩖឋ஺•ூ4-4-1௃ᙠs^_<᝞ᨵH$ᨬḄ^_ᙠᨬᑁᨬḄ^_ᙠᨬ᜜pCPUᑗ^_Ḅnᦪ஺᝞4-4(b)Ḅᦔ᳛4-4(a)Ḅj஺for(row=0;row<100;row++)for(col=0;col<5;col++)({for(col=0;col<5;col++)for(row=0;row<100;row++){(sum=sum+a[row][col];sum=sum+a[row][col];})))4-4(a)|ᦔ᳛^_ᙠᨬ᜜4-4(b)jᦔ᳛^_ᙠᨬᑁூ4-4-2௃᝞^_wᑁᙠᑨ¡¢£^_nᦪoᜧ¥$ᑨ¡¦ᑮ

29^_wḄ᜜☢஺4-4(c)Ḅ4-4(d)᡻©N-1nᑨ¡஺¢£ᵫ¬ὅὁ⌕°©ᑨ¡ᡭ¡^_“³´µ”·¸f¹/0ᘤº^_°©»ᓄᜐᳮ{|ᦔ᳛஺᝞N¿ÀᜧᨬÁÂᵨ4-4(d)Ḅᑏ4xjᦔ᳛஺᝞N¿ÀÃÄὅᦔ᳛ÅÆ¢ÇÈÂᵨ4-4(c)Ḅᑏ4ÉÁ8!XYZÊ஺for(i=0;i

30switchᑖ÷⌱ù`a(if`aúᨵÄûᑖ÷ü⌱ù஺ýᯠᵨÿᝅḄifᩭᑖ⌱᪵Ḅᑍ஺switchᙠḄᳮᵫ஺switchḄ$%&'(switch(variable)(casevaluel:break;casevalue2:…break;default:break;)•ூ;ᑣ4-6-11=>caseḄ?@A⌕CDEbreak,ᔲᑣHIJ>ᑖKL(◀NᨵPQ>ᑖKL)஺•ூ;ᑣ46-2௃A⌕CSᨬU>defaultᑖ஺ᓽQWḄA◤⌕defaultᜐᳮZ[\]ᶇdefault:break;᪵_`NabcdeD■ghijkelCDdefaultᜐᳮ஺4.7gotomno᎝?᪀ᓄstkᩭgot஺wᡂDᨵyzḄ஺✌ᐜᵫ}goto~kᮣ᝞AE▲ᑴḄẚ?᪀ᓄst&஺ᐸgot஺ᩭ┯jᡈ◚஺~DḄ᪀⌼ஹḄ¡ᓄஹK⌕Ḅt¢£¤᝞(gotostate;Stringsi,s2;//¨gotointsum=0;//¨gotostate:᝞¬ᘤA¯°a±┯j=ᵨbgoto³~ᶇ´◚஺µi¶z·◀C++/CḄgotokºU஺»¼ᙢ¾┯jᕒmÀ⌼ᡂḄAgot஺Ḅ┯஺gotoÁÂᨵbᜐ~ÃÄÅnKÆÇÈÉÊᙢb´Ëᑮ᜜☢ᵨAḼᑏµḄbreakѤ᝞gotoerror;

31error:wÒÓḼÔDᩭAÕnÒÖb×b×Ø´Ù~nÚÛÜÔᙷ஺ᡠkᡃàáâÂᵨஹãᵨgotodAἭᵨ஺

32å5æbç᪗éêḄëᙠìíîïឤñA஺Còᵨ#defineᩭñôõöe÷ø஺C++ò◀D#define᜜ù~kᵨconstᩭñôõöeconstø஺5.1eúû◤⌕᝞AQᵨüýᙠÉþᑏᦪᡈᨵ1Ḅឋᳮឋ஺ᕒ!ᦪᡈ#$%ᵨᡝᑣ)*+,-./0ᜐᩭஹ⊤5஺2ᙠḄ89ᙢ;<ᐭ>᪵Ḅᦪᡈ@A+BCDᑏ┯G஺3᝞J⌕Lᦋᦪᡈᑣᙠ89ᙢ;ᦋNOPQ᧕S┯஺•ூWᑣ5-1-11XYZᵨ[\]^Ḅ_Yᩭ⊤5!ᙠ`9aSbḄᦪᡈ஺c᝞dtfdefineMAX100/*CrsḄt_Y*/constintMAX=100;//C++rsḄconst_YconstfloatPI=3.14159;//C++rsḄconst_Y5.2const#defineḄC++rsᵨconstᩭ\_Yᵨ#defineᩭ\_Y஺#ὅὅᨵ)9Ḅd1const_Yᨵᦪt_Yᨵᦪ஺ᘤὅᐰ஺ὅᣚᨵᐰ¢£ᙠᣚ¤¥C$ᧇ+ᑮḄ┯G¨▭ᦔ«஺2ᨵ!¬ᡂᓄḄ¯°±ᐹconst_Y¯°#+¤t_Y¯°஺•ூWᑣ5-2-11ᙠC++`Zᵨconst_Y+Zᵨt_Yᓽconst_Y´ᐰµ¶t_Y஺5.3_Y\WᑣூWᑣ5-3-1௃◤⌕᜜º»Ḅ_Y¼ᙠᜮᦻ¿`+◤⌕᜜º»Ḅ_Y¼ᙠ\ᦻ¿ḄᜮÀ஺ÁÂÃÄᳮÅ+>ÆᙽḄ_Y¬`ȼᙠÉʺᐳḄᜮᦻ¿`஺ூWᑣ5-3-21᝞JÌÉ_Yᐸ-_YÎᑗÐᐵ«ᙠ\`ᒹ[ÓÔᐵÕ+

33«ÖSÉ!×ØḄÙ஺c᝞dconstfloatRADIUS=100;constfloatDIAMETER=RADIUS*2;5.4`Ḅ_Yᨵàᡃ.âãÌ!_Yᙠ`ᨵᦔ஺äÃ#define\Ḅt_Y#ᐰåḄ+¤æᑮçḄÃ#èéᯠᙢëì«íᵨconstL⛲ᦪᡂᕒᩭïb஺constᦪᡂᕒḄð#ÈᙠḄᐸ[\ᓾ+#ᡃ.ᡠóãḄ஺constᦪᡂᕒᙠÌÊôCÈóᑁ#_YÃ᦮Êsᓾ#Ḅ÷Áøù9Êô+>ḄôᐸconstᦪᡂᕒḄÙ+>஺+¤ᙠúû`üýᓄconstᦪᡂᕒ஺þᵨÿ┯ḄḄᘤ⍝SIZEḄ஺classA(•••constintSIZE=100;//┯./ᙠ12345ᓄconstᦪ8ᡂᕒintarray[SIZE];//┯ḄSIZE)@constᦪ8ᡂᕒḄ45ᓄABᙠ᪀⌼EᦪḄ45ᓄ⊤3GHI᝞classA{…A(intsize);//᪀⌼EᦪconstintSIZE;);A::A(intsize):SIZE(size)//᪀⌼EᦪḄ45ᓄ⊤)Aa(100);஻aḄSIZE100Ab(200);//bḄSIZE200S᪵UBVᙠ᦮X3Yឤ[Ḅ\]ᕖ_`ᢣbconstᦪ8ᡂᕒcdeᵨ3Ḅgh\]ᩭjk஺I᝞classAenum{SIZE1=100,SIZE2=200);//gh\]intarray1[SIZE1];

34intarray2[SIZE2];o@gh\]pᓰᵨḄrstuvwᙠᐰyz஺gh\]Ḅ{|:vḄ◚~ᦪ8᦮ᦪᐸᨬᜧᨵ▲B⊤|ᦪ᝞PI=3.14159o஺

356EᦪEᦪC++/CḄBᓫᐗᐸ⌕ឋ஺EᦪḄ¡{|¢£᧕¥¦eEᦪ┯ᵨᡠ¨ᐝªEᦪḄB«¬Ḅ஺|®¯EᦪḄ°±²ᑁyjkḄ´µ¶ᑣ஺Eᦪ°±Ḅ¸X⌕¹ºᦪ²»¼஺C½3EᦪḄºᦪ²»¼Ḅ¾⌴ÀÁᨵ¸Âþ⌴(passbyvalue)²ᢣ┐¾⌴(passbypointer)C++½3ÅcÆᵨ¾o⌴(passbyreference)ᵫÈÆᵨ¾⌴ḄឋÉᢣ┐¾⌴ªᵨÀÁᓾ¾⌴4oËὅ\\ÍÎÏ£᧕ÆÐÑÒÓᐜ▅Ö6.6⁚“ÆᵨÙᢣ┐ḄÚÛ”஺6.1ºᦪḄ¶ᑣ•ூ¶ᑣ6-1-11ºᦪḄÞᑏ⌕à᦮⌕á/ḕãAᑏºᦪḄḕᶍºᦪåæ஺᝞çEᦪèᨵºᦪᑣᵨvoidéᐙ஺I᝞ÃvoidSetValue(intwidth,intheight);//ëìḄíîvoidSetValue(int,int);//ëḄíîfloatGetValue(void);//ëìḄíîfloatGetValueO;//ëḄíî•ூ¶ᑣ6-1-21ºᦪïå⌕ាñò⌕ᔠᳮ஺I᝞ᑏæõö÷øEᦪStringCopy,vᨵ¸Xºᦪ஺᝞çùºᦪåæÐstrl²str2,I᝞voidStringCopy(char*strl,char*str2);úᡃw¢üýþÿstrlᑮstr2,᎔ᩭ஺ᦪᨵ᝞strSourcestrDestination஺᪵"#$%&'(strSourceᑮstrDestination«ᨵ)*+⚪-*ᦪ.)*(ᙠ0.)*(ᙠ12ᦪḄ45⌕⍳895ᕒḄ;<஺)=ᙢ'?@ḄᦪAᙠ0☢CᦪAᙠ1☢஺᝞D?EᦪFGHIvoidStringCopy(char*strSource,char*strDestination);JKᙠLᵨNOPQᎷSTᙢᑏᡂ᝞WXYIcharstr20;StringCopy(str,"HelloWorldw);//ᦪ45Z᎔•ூ^ᑣ6-1-31᝞Dᦪᢣ┐bcdeᐭᵨᑣ'ᙠgh0iconst,■k(ᢣ┐ᙠEᦪlᑁn᜜pᦋ஺r᝞I

36voidStringCopy(char*strDestination,constchar*strSource);•ூ^II6-1-41᝞Deᐭᦪst⌴ḄvYt⌴wxᑣyᦋᵨ“const&”vYᩭt⌴᪵ḕ{|NwxḄ᪀⌼᪆᪀9"ᦔ᳛஺ூ6-1-11EᦪᨵḄᦪᦪ*ᦪᑴᙠ5*ᑁ஺᝞DᦪᙠLᵨN᧕?ᦪghᡈ45┯஺ூ6-1-21Q⌕Lᵨghᦪ@QḄᦪ஺C᪗EᦪprintfᵨQᦪḄᐺh⊤ᐸhHIintprintf(constchat"format,argument1•,•);¡¢ḄEᦪᙠ£¤N¥ᜫ§¨¢Ḅgh©ᐰ«¬஺6.2®sḄ^ᑣ•ூ^ᑣ6-2-11Q⌕ḕᶍ®sḄgh஺C°±²Qigh³GḄEᦪ)´µ¶ᢥ᦮hᜐᳮ஺᪵»QPᨵ¼½ᜐᓾ᧕n¿ÀHvoidgh஺C++°±ᨵÁ¨¢Ḅgh©ᐰ«¬QᐕÃ#ÄÅÆÇÈ஺ᵫÊC++95ËᵨCEᦪH§ÌÍ^ÎÏC++/CEᦪÐÑÒᨵgh஺᝞DEᦪÓᨵ®s.½'FGHvoidgh஺•ூ^ᑣ6-2-21EᦪÔ®sghᙠ°#QÕÖ஺×Øᩩ^ᑣḄᐺh⊤C᪗Eᦪgetcharor᝞Icharc;c=getchar();if(c==EOF)ᢥ᯿getcharḄS?ÛcFGHcharghÁµᯠḄÝÅ஺ÞQßḄgetcharḄQcharghintghᐸh᝞WIintgetchar(void);ᵫÊccharghàsâ-128,127,᝞DãEOFḄsᙠcharḄàsâä᜜.½if°å?æᜫç“ᓻ◅”Kì)=íîᧇᑮðñòór┯¿ḄôÎõQᙠᵨᡝEᦪgetchar¿ñ§Lᵨὅ஺•ூ^ᑣ6-2-31Q⌕?øùs┯¿᪗úÌᙠ)®஺øùsᵨe&ᦪû┯¿᪗úᵨreturn°å®஺®ü#rC᪗EᦪḄýþὅH¼½⌕?getcharFGHKÿḄintᕖ

37ᔩᙠgetcharḄᓫ!஺#᝞%getchar&ᑮᦻ)*+᪗-ᡈ/01┯34567᪗-EOF஺;<=>?Ḅ!@ABEOFCD;Eᦪ(H;E1)஺KLMᦪgetcharNᡂ

38m_data=newchar[strlen(other.data)+l];strcpy(m_data,other,data);return*this;//Ḅ*thisḄÄᵨä◤£¤åæ)¾?ÓhMᦪfçᵨ“ÄᵨÅ⌴”ḄèString¾¿஺᝞%ᵨ“hÅ⌴”ḄèᯠéÎêᯠ#ᵫ?returnuv⌕ì*this£¤ᑮíîhḄ᜜ðîñᓫᐗóX<5⌕Ḅk├õö<ÓhMᦪḄᦔ᳛஺᝞mStringa,b,c;a=b;//᝞%ᵨ“hÅ⌴”Bø07ù*this£¤a=b=c;//᝞%ᵨ“hÅ⌴”Bø0úù*this£¤StringḄÕMᦪoperate+ḄTd᝞mStringoperate+(constString&sl,constString&s2)(Stringtemp;deletetemp,data;//temp,dataûü'\0'Ḅ!¢temp.data=newchar[strlen(sl.data)+strlen(s2.data)+1];strcpy(temp,data,si.data);strcat(temp,data,s2.data);returntemp;}ᦪᵨ“⌴”ḄString஺᝞ᦋᵨ“ᵨ⌴”!ᦪ"#$ᢣᔣ'(tempḄ“ᵨᵫtempᙠᦪ./0123├5678Ḅ“ᵨ”9ᦔ஺;᝞

39ூUᑣ6-3-2௃ᙠᦪpḄ“urᜐ”return§¨Ḅឋtᦔ᳛஺᝞ᦪᨵ!ᦪḄ“urᜐ”"return§¨஺ᡃmF⌕«¬return§¨஺᝞return§¨ᑏKF®ᦪ⌕!u┯⌕!ᦔ᳛¯N஺°±²⚗᝞N<(1)return§¨Fnᢣᔣ“᪘ᑁ¶”Ḅ“ᢣ┐”ᡈὅ“ᵨ”º»ᑁ¶ᙠᦪp./0123├5஺;᝞char*Func(void)(charstr[]="helloworld";//strḄᑁ¶È᪘Éreturnstr;//678┯}(2)⌕ÌÍÎḄÏÐ"“”ஹ“ᢣ┐”Ò"“ᵨ”஺(3)᝞ᦪ"#$⌕ὃ⇋return§¨Ḅᦔ᳛஺;᝞returnString(sl+s2);Ö"×0Ḅ§a⊤Ù''ÛÜ#$×0EÝ”஺F⌕o»ÝÞ“ᐜÛÜ#$'(tempEÝḄ.”"àáḄ᝞Stringtemp(si+s2);returntemp;S}FᯠÉãäṹ6æçèé²஺✌ᐜtemp1ÛÜW0ëᡂìíᓄ<ᯠïðñ᪀⌼ᦪxtempðñᑮô¶Ḅ᜜(¶öᓫᐗùúᨬïtempᙠᦪ./01├5(üᵨ᪆᪀ᦪ)஺ᯠz“ÛÜ#$×0EÝ”Ḅþ"FWḄÿᘤᓄᙠ᜜ᓫᐗḕ᪆᪀Ḅᓄ!"#ᦔ᳛஺'(ᙢᡃ+,⌕.returnint(x+y);//=>?@ABCᑏᡂinttemp-x+y;returntemp;ᵫJᑁᦪM'N᝞int,float,doubleḄ?@,ᙠ᪀⌼XᦪY᪆᪀XᦪZᯠ\“?@Ḅ^_”,a"#bcᦔ᳛defghijk᧕m஺6.4ᐸCopூo6-4-1௃XᦪḄst⌕ᓫ=,⌕uvbᵨ⌶ḄXᦪ஺pூo6-4-2௃XᦪyḄz{⌕|}@~ᑴᙠ50ṹᑁ஺pூo6-4-3]}@Xᦪᨵ“”st஺ḄᐭḄ஺ᨵ“”stḄXᦪᐸte,⚜ḄCḄtJ

40“᝱”஺᪵ḄXᦪ¢,᧕ᳮ¤¥,ᑭJ§¨©஺ᙠC/C++^ªXᦪḄstatic«?@eXᦪḄ“”ᘤ஺o}@cᵨstatic«?@◀®◤஺pூo6-4-4௃,°⌕±²ᐭ³ᦪḄᨵᦔឋµ⌕±²¶·ᐸC⌶¸¹ᐭXᦪyᑁḄ?@Ḅᨵᦔឋº᝞ᐰ«?@ஹᦻ¾¿ÀÁ஺pூo6-4-5ᵨJ┯ᜐᳮḄABÄ=Å⌕ÆÇÈÉᵨὅ,Ë᧕ÌÍᡈϤ┯ÏÐÑ஺6.5ÉᵨÒªfg=ÓᑖDebug᱐ÖRelease᱐ÖDebug᱐ÖᵨJᑁקRelease᱐ÖØÙᵨᡝÉᵨ஺Òªasserte°ᙠDebug᱐ÖÛÜᵨḄÝCᵨJ±²“,\”ØḄÐÑ஺Þº6-5e=>ᑁßᑴXᦪ஺ᙠà·f᝞áassertḄ³ᦪᎷãäfgåaæç=Óᙢµaè"ÞéêëᙠìäᙢíîØassert஺void*memcpy(void*pvTo,constvoid*pvFrom,size_tsize)(assert((pvTo!=NULL)&&(pvFrom!=NULL));//ÉᵨÒªbyte*pbTo=(byte*)pvTo;//■æᦋ?pvToḄᙢᙬbyte*pbFrom=(byte*)pvFrom;//■æᦋ?pvFromḄᙢᙬwhile(size—>0)*pbTo++=*pbFrom++;returnpvTo;}Þº6-5ßᑴ,òóḄᑁᙽassert,e=>õö÷øÛᩭḄÝ஺,ᙠfgḄDebug᱐ÖRelease᱐ÖîÛúûassert,\üýþÜᵨ஺ᡠassertᦪ஺ᕒassertᡂᙠ᝱ᐰᵨḄ!"#$%஺᝞'ᙠassertᜐ)*+,-.ᨵ0assertḄᦪᨵ┯23ᵨὅ5+6┯assert78ᡃ:;ᑮ=>┯2Ḅ?@஺ABᨵCDEᑮḄFGᓾI⍝0FGḄKᵨLMNOPḄQ+஺Rᓄ+ATUVW+᣸◀┯2ZW+[\]^┯2ᑮ_`a஺ᨵḄU᎛ᕒᏔdefgh5ᨵ┯2ḄFG஺ᡠ᝞'j\]FGklḄ`amAnᑨF┯25pᙠqe5pᙠFGq஺rsḄ^t⚪AvwxZ⌕z{\ᨎḄ}~ᓽ஺^᧕ḄQABᨵᕒ^᪵஺^vCNᙠ᪍ᑮ᪛{┑Ḽᙽ“ᓻ◅”Ḅᜧ஺ᓻ◅ᑮ_`a᪛⌕᎔ᨵᨵ◀N:“ᓻ◅”`aᔲᑣ^¡n¢ᑮ£᩽ᨵᦔḄKᵨ஺nᳮwḄFG§§¨ᕒ©ᶍ,¬¨ᑤ◀஺Maguire,p8-p30

41•ூ²ᑣ6-5-11ᵨFGᣓᣍµ0=>Ḅ¶·஺⌕¸¹¶·º┯2·»VḄ¼½¾ὅ¿ᯠÁᙠḄ,ÂÃ⌕K5ᜐᳮḄ஺•ூ²ᑣ6-5-21ᙠᦪḄᐭÅᜐᵨFGklÆᦪḄᨵᦔឋÈᔠ¶ឋÊ஺•ூËÌ6-5-11ᙠÍᑏᦪU⌕ÏÐÑÒḄὃl,ÂÔtÕ“ᡃᡭ×ØÙᎷÔÛÜÃ+ḄᎷÃm⌕ᵨFGÝᎷÃÏÐkl஺•ூËÌ6-5-21Þᦟàáâãᕒ:ÏÐ■┯gh⌕åæ^çÍèéêf◚Ṱ┯2஺íÏÐ■┯ghU᝞'“ê=>”ḄQḄÜ=>+ᑣ⌕ᵨFGÏÐî¡஺6.6ïᵨºᢣ┐ḄCòïᵨC++qḄᭆö÷øὅù᧕ïᵨúᢣ┐¸¹¢஺qnmḄïᵨÈreference,mᵨᱥreferent஺intm;int&n-m;nmḄnḄ!mḄ஺"᝞ᨵ%&'()*Ḅ“,)”஺.“,)”/0/0Ḅᐸ2!'().,⍝4஺ᡠ6n78mḄ9:;8ᢣᔣmḄᢣ┐ᐸ2n!m?@A஺ᵨḄBCDᑣ᝞FG1ᵨIJḄKLMNOPᓄᢣ┐ᑣR6ᙠL᎛OPᓄ஺28VᨵNULLᵨᵨMNZᔠ\Ḅ]^ᓫᐗᐵὶᢣ┐ᑣR6NULL஺3BdᵨOPᓄ!8VᦋfᵨḄᐵgᢣ┐ᑣR6hLᦋfᡠᢣḄi஺6Fj"klmkOPᓄoiḄᵨ஺pqk=jt8VukvᦋᡂojḄᵨxykḄzᦋfᡂo6஺ᵫkiḄᵨᡠ6iḄz;fᡂ}6஺inti=5;intj=6;int&k=i;k=j;஻1iḄzfᡂ}6:☢ḄklᩭiᙠᦻᨵᵨḄz஺ᵨḄ⌕V⌴ᦪḄᦪz஺C++pmᦪḄᦪzḄ⌴¡¢ᨵ,£Gz⌴ஹᢣ┐⌴ᵨ⌴஺6F“z⌴”Ḅj"kl஺ᵫFunclᦪᑁḄx᜜«f¬nḄB9:ᦋfxḄz8®¯°n,ᡠ6nḄz±ᯠ0஺voidFunclintxx=x+10;}

42intn=0;Fund(n);cout<<"n="<

43%7ᑁ'(ᳮ*+,ᐭᑁ'.ᱏ01஺2ᜧḄBillGates<=ᜫ?@640Koughttobeenoughforeverybody—BillGates1981TUᕒW=XYᑏᑁ'(ᳮTU[[\]^_஺᝞`a0b•ḄdefghijᡠᨵlmḄᙢ0op᣸◀sWthtḄ஺Ḅᑁuvwxᦟz{Ḅ⌕}ᐭ~ὅ◤]▅ᑮᙢ᧽ᑁ'(ᳮ஺7.1ᑁ'ᑖᑁ'ᑖᨵ@(1)☟᝱'1ᑖ஺ᑁ'ᙠTUYḄ᎛=ᑖ.ᙽᑁ'ᙠTUḄ᦮¡¢'ᙠ஺£᝞ᐰ¥¦§static¦§஺(2)ᙠ᪘«¬஺ᙠ᡻®ᦪ®ᦪᑁ¥°¦§Ḅ'ᓫᐗ¢³´ᙠ᪘«¬®ᦪ᡻µ¶.·'ᓫᐗ¸¹º»¼஺᪘ᑁ'ᑖ½ᑁ¾¿ᜐᳮᘤḄᢣÃÄÅᦔ᳛ÈÉÊhᑖḄᑁ'u§ᨵ▲஺(3)ᚮᑖÎϹ᝱ᑁ'ᑖ஺TUᙠḄ᎛ᵨmallocᡈnewᵭÕÖ×~ØḄᑁ'TUᕒ¸ÙÚÛᙠÜᵨfreeᡈdelete»¼ᑁ'஺¹᝱ᑁ'ḄÝ'ᵫᡃWeàáᵨâXᮣäÊå⚪çᨬ~஺7.2XéḄᑁ'┯ëìᐸîïiÝᑁ'┯ëhâXðñḄòó஺Yᘤô¸¹ij.·┯ëXhᙠTUõôᣓᣍᑮ஺ø.·┯ëᜧ~ùᨵúḄûü◚jþÿᦋ┯Ḅ஺ᨵᵨᡝ᝼ᙢᩭᓾᨵ⚪┯!"஺#$Ḅᑁ&┯'ᐸ)*᝞,-♦ᑁ&ᑖ01ᡂ3ᓾ4ᵨ5஺678#9:;┯<=>?ᨵ@Aᑮᑁ&ᑖ0CDᡂ3஺#ᵨEFGHIᙠ4ᵨᑁ&KLMNᢣ┐Iᔲ=NULL஺᝞Uᢣ┐pIWᦪḄYᦪZ[ᙠWᦪḄᐭ]ᜐᵨassert(p!=NULL)hiMN஺᝞UIᵨmallocᡈnewᩭᵭrᑁ&stᵨif(p==NULL)ᡈif(p!=NULL)hi■┯ᜐᳮ஺♦ᑁ&ᑖ0yᯠᡂ3{I|1}~ᓄᵨ5஺9:;┯⌕ᨵ<-Iᨵ}~ᓄḄI=ᑁ&Ḅḕ}ᐰ=ᵨ}┯(᝞ᦪ)஺ᑁ&Ḅḕ}I[ᨵḄ᪗ᨵ᎛=ᡃ?¡¢£

44ᐸ¤D¢£ᐸᨵ஺ᡠ¤¦ᵨ;§¨©ªᦪ«¬®}ᓽ°I®±D¢ḕᶍD⌕³´µ஺♦ᑁ&ᑖ0ᡂ3¶·¸}~ᓄ{¹"º»ᑁ&Ḅ¼½஺᝞ᙠ4ᵨᦪ¸#,᪗“¿1”ᡈὅ“Á1”Ḅ¹"஺ᱯ¬IᙠforÃÄÅÆÇÃÄÈᦪÉÊ᧕Ì┯ᦪ¹"º½஺♦ÍÎÏᑁ&⌼ᡂᑁ&Ñ☄஺Óᨵ:;┯ḄWᦪÔÕÖᵨÈ×ᜫᙽᑁ&஺ÚÛ~ÜḄᑁ&ᐙÞßDᑮ┯஺àᨵÈáᯠâᣵÜäåæç-ᑁ&ὑ஺é᝱ᑁ&ḄᵭrëÎÏìí0)ÇmallocëfreeḄ4ᵨÈᦪî⌕ïðᔲᑣòîᨵ┯ónew/deleteðᳮô஺♦ÎÏᑁ&ᓾõö4ᵨ5஺ᨵ÷;øù-ó1ôÇḄ)úÖᵨᐵÜ»üýᩖÿᙠᔲᑁᦪ᪀"᪷$%&'(ᳮḄ+,-☢஺20ᦪḄreturn12ᑏ┯567⌕9:ᢣᔣ“᪘ᑁ”Ḅ“ᢣ┐”ᡈὅ“Cᵨ”,FGᑁᙠ0ᦪHIJKL├N஺3OᵨfreeᡈdeleteᑁPQᨵSᢣ┐TGNULL஺UVWX“Yᢣ┐”஺•ூ]^IJ7-2-11ᵨmallocᡈnewᵭ`ᑁaPbᓽdeᢣ┐fᔲGNULL.■hOᵨᢣ┐fGNULLḄᑁ஺•ூ]ᑣ7-2-2௃7⌕klGᦪmnL᝱ᑁpqf஺■hSrJqsᓄḄᑁuGvfOᵨ஺•ூ]ᑣ7-2-31wxᦪmᡈᢣ┐Ḅy᪗{|ᱯ~⌕X“1”ᡈὅ“1”u஺•ூ]ᑣ7-2-41L᝱ᑁḄᵭ`■hᑁ஺•ூ]ᑣ7-2-5௃ᵨfreeᡈdeleteᑁaPbᓽSᢣ┐TGNULL,■hWX“Yᢣ┐”஺7.3ᢣ┐ᦪmḄC++/Cᢣ┐nᦪmᙠ7ᙢᣚḼᵨWX┯GὅḄ஺ᦪm⌕ᙠ☟᝱¡¢J£¤¥᝞ᐰ-ᦪm¨⌕ᙠ᪘%J£¤஺ᦪm©Ḽ¥ª7ᢣᔣ¨ᙽᑁᐸᙢᙬ®¯ᙠX°±ᑁ²ᢝ7´µᨵᦪmḄᑁ®ᦋ´஺ᢣ┐·ᢣᔣ¸6¹ºḄᑁᙽ»Ḅᱯ¼“´”ᡠᡃ¿Àᵨᢣ┐ᩭuL᝱ᑁ஺ᢣ┐ÂᦪmᮣÄÅÆÇᓻ◅஺

45y☢ÊËÌGÍÎᢣ┐ᦪmḄᱯឋ஺7.3.1cᦋᑁeÐÍ7-3-1ÊËᦪmaḄ®¯6ÊËᐸᑁ®GhelkAO஺aḄᑁ®ᦋ´,᝞a[0]=ᢣ┐pᢣᔣÀ¯ÊËÌ“world”(çè☟᝱¡¢ᑁ®Gworld'஺)À¯ÊËÌḄᑁ®7JëᦋḄ஺"1ì%íîïᘤñ7ò12p[OJ=Xᨵõ7öÅ12÷øëᦋÀ¯ÊËÌḄᑁ®ªUVùú┯û஺chara[]="hello”þa[0]='X';cout<ᑴ@AB஺-.7-3-2HIJKLᦪ2aḄᑁ7>ᑴMᦪ2b,&'ᵨQRb=a,ᔲᑣUVW#$┯,.Y*ᵨ᪗[\]ᦪstrcpy:;>ᑴ஺`ᳮIABb3aḄᑁ7bᔲc`I&'ᵨif(b==a)ᩭᑨjIY*ᵨ᪗[\]ᦪstrcmp:;AB஺QRP=am&'LaḄᑁ7>ᑴᢣ┐p,nbLaḄᙢᙬqMrp஺⌕K>ᑴaḄᑁ7Ituᐜᵨ\]ᦪmallocwpᵭyzᙽ7wstrlen(a)+l}Ḅᑁ~Iᵨstrcpy:;>ᑴ஺`ᳮIQRif(p==a)ABḄ&bᑁ7nbᙢᙬIY*ᵨ\]ᦪstrcmpᩭAB஺//ᦪ2…chara[]="hello”;charb[10];strcpy(b,a);//&'ᵨb=a;if(strcmp(b,a)==0)//&'ᵨif(b==a)//ᢣ┐…intlen=strlen(a);char*p=(char*)malloc(sizeof(char)*(len+1));strcpy(p,a);//&⌕ᵨp=a;if(strcmp(p,a)==0)//&⌕ᵨif(p==a)-.7-3-2ᦪ23ᢣ┐Ḅᑁ7>ᑴ@AB

467.3.3hRᑁeiᵨsizeoftuᦪ2Ḅ7(⁚ᦪ)஺-.7-3-3(a)HIsizeof(a)Ḅb12(rᢣ┐pᢣᔣa,bsizeof(p)Ḅᓾb4஺bwsizeof(p)ᑮḄbz}ᢣ┐Ḅ⁚ᦪ,csizeof(char*)In&bpᡠᢣḄᑁ~7஺C++/CQᨵ⍝ᢣ┐ᡠᢣḄᑁ~7I◀ᙠᵭyᑁ~¡¢£¤஺jklᦪ+mnᦪḄoᦪpOq⌴sWtᦪ+uv⌨ᓄny"zḄᢣ┐஺~7-3-3(b)HI&¥ᦪ2aḄ7b¦§Isizeof(a)¨©ªsizeof(char*)஺chara[]="helloworld”;char*p=a;cout<

47ÐÑᙠ]ᦪGetMemoryH஺#$ᘤÒb⌕w]ᦪḄÓ}°ᦪᑴÔÕ¡Ö×Iᢣ┐°ᦪPḄÖ×b_p,#$ᘤ¾_P=P஺᝞¶]ᦪÙᑁḄÚÛ/ᦋr_pḄᑁ7IÜÝÞ°ᦪPḄᑁ7ÔcYḄ/ᦋ஺Übᢣ┐tuᵨÔß°ᦪḄà஺ᙠ×.HI_pᵭyráḄᑁ~IâbLPᡠᢣḄᑁ~ᙢᙬᦋrIbPãäå஺ᡠu]ᦪGetMemorym&'ßæ²çè஺éêëIÓ᡻;•îGetMemoryÜïð☄zᙽᑁ~Iwᨵᵨfreeòóᑁ~஺᝞¶⌕ᵨᢣ┐°ᦪ¸ᵭyᑁ~IôÇY*ᦋᵨ“ᢣᔣᢣ┐Ḅᢣ┐”Iö-.7-4-2஺voidGetMemory2(char**p,intnum)(*p=(char*)malloc(sizeof(char)*num);}_______________________________________________________________________voidTest2(void)(char*str=NULL;GetMemory2(&str,100);//°ᦪb&str,n&bstrstrcpy(str,஻hello஻)cout<

48ᵨ?ᦪAᩭ⌴᝱ᑁBᯠDᵨEFGHHᨵJKreturnLMᵨ┯O஺PQRS⌕ᵨreturnLMAᢣᔣ“"Ḅᢣ┐EZ[\ᑁᙠ?ᦪ^_`abcE7-4-4஺char*GetString(void)(charp[]="helloworld”;returnp;//klᘤnopqr}voidTest4(void)(char*str=NULL;strsGetStringO;//strḄᑁuGᚗwcout<

497.5free¶deleteKᢣ┐ᖾ¸¹free¶deleteḄºូ¼¼Ḅ(½ᐸGdelete),¡¿³GKᢣ┐ᡠᢣḄᑁÁÂÃᣵEFÅÆᨵKᢣ┐ÇÈÉᣵ஺ᵨRyᘤ|}7-5,~ᢣ┐pÊfreeËᐸᙢᙬÎᯠS©(ÏNULL),³G\ᙢᙬÐÑḄᑁGᚗwEpᡂO“Òᢣ┐”஺᝞Ó`SKpÔ[NULL,ÕJË[pG²ᔠḄᢣ┐஺᝞¢£×ØÙEᡃ¿ᨵ`ÛSÜpᡠᢣḄᑁGᔲÞßÊÂÃEᙠàáâᵨpãäEåHᵨLMif(p!=NULL)ç■┯ᜐᳮ஺ë⍡íEÓ`ifLMîSᑮ■┯ðᵨEZ[ᓽòpSGNULLᢣ┐E¡óSᢣᔣᔠḄᑁᙽ஺char*p=(char*)malloc(100);strcpy(p,"hello");free(p);஻pᡠᢣḄᑁÊÂÃEFGpᡠᢣḄᙢᙬÎᯠS©if(p!=NULL)//Æᨵîᑮ■┯ðᵨ(strcpy(p,"world");//p┯7-5pᡂ[Òᢣ┐7.6᝱ᑁÊaÂÃᔩ?ᦪöᑁḄ÷ø©ᙠ?ᦪ^_`abc஺ëùJË[7-6GûüḄ஺ᳮᵫGpG÷øḄᢣ┐©E¡bcḄ`᎛Õ¡ᡠᢣḄ᝱ᑁ±îþÿ஺┯voidFunc(void){char*p=(char*)malloc(100);//᝱ᑁ!"#$%ᔩ'})*7-6+,-᝱ᑁ!#$%ᡃ/01ᢣ┐ᨵ56“89:”Ḅᱯ>?(1)ᢣ┐+,-./%⊤12ᡠᢣḄᑁ56789:;஺(2)ᑁ57:;-./%⊤1ᢣ┐6+,ᡈὅᡂ-NULLᢣ┐஺⊤A$%ᑁ!BC5DEF₝᳛IJḄK஺LMᨵNCOPQ5R⌕TUEF₝᳛VKḄᳮᵫ?᝞Z[\]^_`VQ5ᑗᢣ┐b"cdQ᝱ᑁ!"efghijᦈ஺lᯠ᝞n,

50ᙠ[\q]rQsEFCt$%ᑁ!ஹCtvᢣ┐wxyNULL_஺]}EFᏕ9C"0┯_ᔳ'஺᝞ZN[\Uᩭᵨᑮᐸᙢ'7.7“ᢣ┐”“ᢣ┐”CNULLᢣ┐Qᢣᔣ“ᚗ”ᑁ!Ḅᢣ┐஺N/5C"┯ᵨNULLᢣ┐Qyᵨif¡᧕ᑨ¤஺¥“ᢣ┐”ᓻ◅ḄQifIC¨gᵨ஺“ᢣ┐”Ḅᡂª⌕ᨵ«¬?(1)ᢣ┐®¯ᨵe°±ᓄ஺³´ᢣ┐®µe¶·¸C"#ᡂyNULLᢣ┐QḄ¹ḕ»¼½ḄQ"¾ᢣ5P஺ᡠFQᢣ┐®ᙠ¶·ḄÀ¸ÁÂe°±ᓄQ⌕vᢣ┐wxyNULL,⌕-ᢣᔣᔠÄḄᑁ!஺*᝞char*p=NULL;char*str=(char*)malloc(100);(2)ᢣ┐pefreeᡈὅdeleteËÌQ¯ᨵxyNULL,-NFypÍᔠÄḄᢣ┐஺ÎÏ7.5⁚஺(3)ᢣ┐fgÕÖ_®ḄgᵨØ஺¬ÙÚ-N■CÜ■Q)*[\᝞Ý?classA(public:voidFunc(void){cout<<"FuncofclassA”<Func();஻p“ᢣ┐”)ìᦪTestᙠ᡻Vp->Func()¸QIïaðñcᜫQ9pᢣᔣaḄQᡠFpsᡂ_“ᢣ┐”஺¥᜻ôḄᡃ`VÍ[\¸õᯠ¯ᨵU┯QEö÷øùᘤᨵᐵ஺

517.8ᨵ_malloc/freeyüý⌕new/delete?malloc÷freeC++/CḄ᪗ᦪnew/deleteC++Ḅ஺ᵨᵭ᝱ᑁ"#$%ᑁ"஺&'ᑁ(ᦪ)*+Ḅ&,-ᐝᵨmaloc/free5678᝱&,Ḅ⌕:஺&,ᙠ<=Ḅ>?⌕@᡻B᪀⌼ᦪ&,ᙠEFGH⌕@᡻B᪆᪀ᦪ஺ᵫmalloc/freeᦪ-KKᙠLMᘤOᑴᩗ▲GᑁKSTU᡻B᪀⌼ᦪ#᪆᪀ᦪḄVWXYmalloc/free஺Z[C++◤⌕^S_ᡂ᝱ᑁ"ᑖb#cdᓄfgḄnew,ij^S_ᡂkᳮm$%ᑁ"fgḄdeleteononew/deleteKᦪ஺ᡃᐜrsrmalloc/free#new/delete᝞uvw&,Ḅ᝱ᑁ"xᳮyz{7-8஺classObj{public:Obj(void){cout<<"Initialization”<Initialize();//cdᓄ//...a->Destroy();//k◀fgfree(a);//$%ᑁ"}voidUseNewDelete(void)(Obj*a=newObj;//ᵭ᝱ᑁ"cdᓄ//...deletea;//k◀$%ᑁ"}z{7-8ᵨmalloc/free#new/delete᝞uvw&,Ḅ᝱ᑁ"xᳮ*ObjḄᦪInitialize¡¢᪀⌼ᦪḄ£SᦪDestroy¡¢᪆᪀ᦪḄ£S஺ᦪUseMallocFree¤¥malloc/freeKS᡻B᪀⌼ᦪm᪆᪀ᦪ¦§¨ᵨᡂᕒᦪInitialize#Destroyᩭ_ᡂcdᓄmk◀fg஺ᦪUseNewDeleteᑣ¬ᓫ®¯஺

52ᡠiᡃK⌕±²ᵨmalloc/freeᩭ_ᡂ᝱&,Ḅᑁ"xᳮ³´ᵨnew/delete஺ᵫᑁ(ᦪ)*+Ḅ“&,”¶ᨵ᪀⌼m᪆᪀Ḅ¸¹&-malloc/free#new/deleteº»Ḅ஺¼ᯠnew/deleteḄ£S_ᐰ⌚À¢malloc/free,ÁÂÃC++KUmalloc/freeÄÅÆÇᕖÉÊZÁC++¹ËÌÍ⌕¨ᵨCᦪ-C¹ËÎSᵨmalloc/freexᳮ᝱ᑁ"஺᝞Ïᵨfree$%"new<=Ḅ᝱&,”Ðô&,Z56᡻B᪆᪀ᦪ-SÑÒ¹ËÆ┯஺᝞Ïᵨdelete$%"mallocᵭḄ᝱ᑁ"”ᳮÔÕÖ¹ËK×Æ┯Ø´¹ËḄÙឋÛÜ஺ᡠinew/delete¦§b&Ýᵨmalloc/freeÞs-᪵஺7.9ᑁ"ὑáâÃãÉ᝞Ïᙠᵭ᝱ᑁ"?äKᑮ8TᜧḄᑁ"ᙽmalloc#newèéêNULLᢣ┐îïᑁ"ᵭᜫñ஺òÍᨵóôõöᜐᳮ“ᑁ"ὑá”ø⚪஺(1)ᑨüᢣ┐ᔲÁNULL,᝞ÏᑣþÕᵨreturnÿᦪ஺᝞voidFunc(void)(A*a=newA;if(a==NULL)(return;)}(2)ᑨ$ᢣ┐'ᔲ)NULL,᝞+'ᑣ-.ᵨexit(l)᦮345Ḅ78஺᝞voidFunc(void)(A*a=newA;if(a==NULL)(cout<<"MemoryExhausted^^<

53ᳮᦪ஺]^ᑁ`abὃC++dᵨef஺.gh1ih2ijkdᵨᨬmn஺᝞+o3ᦪᑁᨵqᜐ◤⌕ᵭau᝱ᑁwVxyjkh1iz{|}~hᑁwiVᵨjkh2iᩭᜐᳮ஺q~ᵨexithli,“~ᑏ┯ᜐᳮ45VXRS8~8”~8஺᝞+“ᑁwὑ”᪵ḄVo¡¢ᩭᵨ45£¤¥¦Nᦗ஺᝞+~ᵨexithli¨©45ᩔ«V¬N®¯«஺⍝ᳮ᝞\᝞+~¨±²³´V±²ᙠὁ«·¸®¹º»qḄ¼஺ᨵo3½⌕Ḅ¾¿⌕ÀÁᜧÃ஺ÄÅ32ÆO.Ḅᵨ45ÇÈV¥ÉÊ᪵dᵨmallocZnew,ËÌ~NÍÎ"ᑁwὑ"஺ᡃᙠWindows98ºᵨVisualC++ᑏÓÔÕ45VÖ×7-9஺345®¥Úᙢ78ºÜV᪷~®஺Þ)32Æßᢝ“áw”VᑁwᵨâÓVRuᵨãäåæ⚔è஺ᡃéêᑮãäìᔷìᔷᙢîVWindow98£¤ï|Äðäஹò᪗ô¥õ஺ᡃNO|yo3öÉÄÅ32ÆO.Ḅᵨ45V“ᑁwὑ”┯÷ᜐᳮ45ô¥ᵨᜐ஺ºN¨UnixDWindows45ᕒùú©Óõû┯÷ᜐᳮ45~üᵨVᡃz~ᑏÓVḕÓq஺ᡃ~þ÷Íÿὅ┯ᜐᳮḄᓟᜫᜧ஺voidmain(void){float*p=NULL;while(TRUE)(p=newfloat[1000000];cout<<"eatmemory”<

54ᡃnopqrstuvᙠxy⌕z{“k]}ᣚ”“sizeof”஺♦mallocḄk]void*,ᡠᙠᵨmalloc⌕ᙢk]}ᣚvoid*}ᣚᡂᡠ◤⌕Ḅᢣ┐k]஺♦mallocZᦪ⌕ᵭcḄᑁUk]ᐵᑁUḄ⁚ᦪ஺ᡃn¡int,float¢ᦪ£k]Ḅ¤Ḅ¥ᑗ⁚ᦪ஺H᝞int¤ᙠ16§RS_2y⁚ᙠ32§_4y⁚¨©float¤ᙠ16§RS_4y⁚ᙠ32§_ª4y⁚஺ᨬ¬ᵨ_Qd®Lcout<

55}voidTest(void)Obj*a=newObj;Obj*b=newObj(1);//óh1deletea;deleteb;)᝞ÓᵨnewíîÔÀᦪþÁÏVᵨÔÀḄÕüᦪ᪀⌼Zᦪ஺H᝞Obj*objects=newObj[100];//íî100yï᝱ÔÀÏᑏᡂObj"objects=newObj[100](1);//íî100yï᝱ÔÀḄñÿ1ᙠᵨdeleteᦪᶇ⌕'‘0᝞delete[[objects;//Ḅᵨdeleteobjects;//┯Ḅᵨὅ"#$deleteobjects[0],%ᣵ'᜜99)஺7.12+,-./0ᡃ234ᢈ6┯ḄC++/C78ᕒ:4ᨵ<=>>?@AB᧽ᢣ┐FᑁHIᳮ(ᒹMᡃNO)஺ᡃᨬRSCTUᱯW᝿ᢣ┐YZᡃ[\]+)^ᵨ_`(a1bcCdṹ)fᨵgᵨ+)ᢣ┐ᐰᵨᦪᩭ⚔kᢣ┐lᙠ≶n.oᑖ஺qrᢣ┐stᩭᡃᦋᑏw)_`dṹxyzᑮ|ᐜḄ+~஺ᡃḄᦟs(1)s᝿ᢣ┐⌕gᵨᢣ┐஺0gᵨᢣ┐sᔠḄ78ᕒ஺(2)ᡂ“gᵨᘤ⌲78”ḄSᨵw᪵=\⚪Ḅ¡஺

56]8¢C++£ᦪḄ¤¥ᱯឋ§$CTUḄ£ᦪC++ª«¬®overloaded¶ஹᑁὶ®inline¶ஹconst¾virtualÀÁÂÃᑴ஺ᐸƬ¾ᑁὶÃᑴÇÈᵨ$ᐰÉ£ᦪÊÈᵨ$ËḄᡂᕒ£ᦪconstFvirtualÃᑴÌᵨ$ËḄᡂᕒ£ᦪ஺¬¾ᑁὶᨵᐸÍᜐ0ÏC++TUÐÑÒsÈÓ#ᡂÔÕḄᓤ⚶ØÙᵨ஺¢ÚÛܬ¾ᑁὶḄÝÞFÉ▲ឋAàáâãäå^æÐᵨஹæÐᵨÓç⌕èé┯ᵨ஺8.1£ᦪ¬Ḅᭆë8.1.1¬ḄìíNᯠTUÆ+)ïÈÓᨵðñòḄóôᓽæïϬ஺<öÈÓBoåᦻᩭᑨùæïᑮúsûÁóô஺“ïḄ¬”ÈÓgTUü«ýþ஺᝞“ᔛ”Ḅᓝᑖᨵ⌕ᐹᔛ஺ῖ"#$%₎✏(Ḅ₎)ᨵ*+ᑏ-஺ᙠC++123456ஹ89:;Ḅ<=>ᦪᵨAB=C)⊤Eᓽ>ᦪGH஺I᪵KLMNOPQ>ᦪḄ᧕ᵨឋITC++6UVᵨGHWᑴḄB=ᳮᵫ஺[᝞E[8-1-13Ḅ>ᦪEatBeef,EatFish,EatChicken4ᵨAB=>ᦪCEat⊤EᵨAopḄqᦪr4s஺voidEatBeef(•,,);//4ᦋ|voidEat(Beef…)~voidEatFish(•,,);//4ᦋ|voidEat(Fish…)~voidEatChicken(…);//4ᦋ|voidEat(Chicken…)E[8-1-1GH>ᦪEatC++6UVᵨGHWᑴḄB-=ᳮᵫToḄ᪀⌼>ᦪ◤⌕GHWᑴ஺|C++᪀⌼>ᦪoACq9᪀⌼>ᦪ9ᨵB=C)஺᝞ᵨ<+AḄ-"⌱9ᵨGHWᑴᩭ஺ᡠ4o4ᨵ¡=ACḄ᪀⌼>ᦪ஺8.1.2GHT᝞¢Ḅ<=ACḄGH>ᦪ£ᯠTAḄ>ᦪ¥T᝞¢sᑖḄᕖᡃ¨ᯠᑮ>ᦪª«Ḅ¬=⌕qᦪ®¯°஺᝞AC>ᦪḄqᦪAᒹ²opஹ³2A´µ᧕s¶¥TAḄ>ᦪ஺

57᝞AC>ᦪ··T®¯°opAᨵ¸4sᑖᨵ¸ᓾ9஺[᝞voidFunction(void);intFunction(void);º»¬=>ᦪB=ᨵ®¯°¼=Ḅ®¯°Tintop஺᝞I᪵½ᵨ>ᦪintx=Function();ᑣ4ᑨÀ¶FunctionT¼=>ᦪ஺Á⚪TᙠC++/C123ᡃ4Ãᶍ>ᦪḄ®¯°஺ᙠI+ÅÆÇÈÉᘤË12ᕒÍÎ⍝Ð=Function>ᦪѽᵨ஺ᡠ49☠qᦪÓ9☠®¯°opḄAᩭsᑖGH>ᦪ஺ÈÉᘤ᪷Õqᦪ|=GH>ᦪÖ×AḄᑁÙ᪗ÛÜ஺[᝞ÈÉᘤ|E[8773ḄÞ=Eat>ᦪÖ×"eatbeefஹeatfishஹeatchickenßoḄᑁÙ᪗ÛÜ(AḄÈÉᘤ9Ö×AàáḄᑁÙ᪗ÛÜ)஺᝞C++12⌕½ᵨ$âÑÈÉãḄC>ᦪᎷåæ=C>ᦪḄçè᝞Çvoidfoo(intx,inty);>ᦪÑCÈÉᘤÈÉãᙠé3ḄC)|Bf஺஺ÓC++ÈÉᘤᑣêÖ×ë.foo_int_intßoḄC)ᵨᩭíᢝ>ᦪGHËopïᐰñª஺òLÈÉãḄC)AC++129óª½ᵨC>ᦪ஺C++OôQB=CñªõᣚᢣÜøextern“C”ᩭùúI=Á⚪஺[᝞extern"C"(voidfoo(intx,inty);…//ᐸ¥>ᦪ)ᡈὅᑏᡂextern"C"(ttinclude"myheader.h"…//ᐸCᜮᦻ)C++ᘤᦪfooCᑮfoo!_foo_int_int஺C++ᘤ#$ᖪ&'(C᪗*Ḅᜮᦻ,-extern“C”ᜐᳮᡠ2ᡃ452ᵨ#include89ᵨ:ᜮᦻ஺;<=!>ᦪḄ?@A᪀ᡂDE஺ᐰGᦪHIḄᡂᕒᦪ@!KDELMᦪḄ,ᵨN!@஺O᝞QvoidPrint(•,•);//ᐰGᦪclassAvoidPrint(-);//ᡂᕒᦪ

58!R>PrintᦪḄXᦪᔲ!@᝞ZIḄ[ᡂᕒᦪ⌕]ᵨᐰGᦪPrint,M-_ᡂᕒᦪPrint`aᐰGᦪb]ᵨcd'QQ'᪗f஺᝞::Print(…)h//⊤jPrintᐰGᦪkᡂᕒᦪ8.1.3lm◚oIpqᣚstDEᦪuvwxឋjO8T-3~outputᦪḄXᦪintIp~woutputᦪḄXᦪfloatIp஺ᵫᦪᨵIpᦪl,XᦪcIpqᣚ(M◚oIpqᣚ)஺஺utput(0.5)uv┯LMᘤ!⍝0.5qᣚᡂintfloatIpḄXᦪ஺◚oIpqᣚᙠᙢ52ᓄ¢£Ḅ¤ᑏ¦§5Aᶇ©◚ª஺#includevoidoutput(intx);//ᦪ¶·voidoutput(floatx);//ᦪ¶·voidoutput(intx)(cout«"outputint"<

598.2ᡂᕒᦪḄDEஹ⌚Ã_◚ÄᡂᕒᦪḄDEஹ⌚Ã(override)_◚ÄÅ᧕ÇÈC++¢£ᕒËÌ⌕ÍÎÏᭆÑᔲᑣ┯■!Ô■஺8.2.1DE_⌚ÃᡂᕒᦪbDÕḄᱯ×Q(1)?@ḄÙ(ᙠ@I)h(2)ᦪ?@h(3)Xᦪ!@h(4)virtualᐵÝ5ᨵ5Þ஺⌚ÃᢣàvIᦪ⌚ÃáIᦪᱯ×Q(1)!@ḄÙ(ᑖaãàvI_áI)h(2)ᦪ?@h(3)Xᦪ?@h(4)áIᦪËÌᨵvirtualᐵÝ஺jO8-2TᦪBase::f(int)_Base::f(float)?åDE,Base::g(void)bDerived::g(void)⌚Ã஺ttincludeclassBase(public:voidf(intx){cout<<"Base::f(int)”<ீx<f(42);//Base::f(int)42

60pb->f(3.14f);//Base::f(float)3.14pb->g();//Derived::g(void)}jO8-2-1ᡂᕒᦪḄDEH⌚Ã8.2.2ïðñòḄ◚Äóᑣᩭõõ`aDE_⌚Ã=!Kö÷¦C++Ḅ◚Äóᑣøù⚪ûᩖឋ▽ᯠÿ஺“◚”ᢣḄᦪᐸḄᦪᑣ᝞(1)᝞!ḄᦪḄᦪ"#ᦪ$஺%&$'ᨵ)virtualᐵ23Ḅᦪ45◚(6789:;<)஺(2)᝞!ḄᦪḄᦪ>?#ᦪ@A"ᦪBᨵvirtualᐵ23஺%&Ḅᦪ5◚(678⌚D;<)஺EFGH8-2-2(a)L(1)ᦪDerived::f(float)⌚DBase::f(float)o(2)ᦪDerived::g(int)◚Base::g(float),X$9:஺(3)ᦪDerived::h(float)◚Base::h(float)8X$⌚D஺#includeclassBasepublic:virtualvoidf(floatx){cout<<"Base::f(float)஻«x«endl;}voidg(floatx){cout<<"Base::g(float)"<᪵஺

61voidmain(void)(Derivedd;Base*pb=&d;Derived*pd=&d;//Good:behaviordependssolelyontypeoftheobjectpb->f(3.14f);//Derived::f(float)3.14pd->f(3.14f);//Derived::f(float)3.14//Bad:behaviordependsontypeofthepointerpb->g(3.14f);//Base::g(float)3.14pd->g(3.14f);//Derived::g(int)3(surprise!)//Bad:behaviordependsontypeofthepointerpb->h(3.14f);//Base::h(float)3.14(surprise!)pd->h(3.14f);//Derived::h(float)3.14)EF8-2-2(b)9:ஹ⌚Do◚Ḅ¨©8.2.3᤮ῃ◚◚ᑣ¬$®¯°஺EF8-2-3GHL±²pd->f(10)Ḅ´7µ¶ᵨᦪBase::f(int),"Base::f(int)$¸5Derived::f(char*)◚஺ᵫᦪ310$¹5◚ºᙢ»ᓄ½3¾¿ᡠÁᙠÃÄ&┯஺classBase(public:voidf(intx);ÆjclassDerived:publicBase(public:voidf(char*str);ÆjvoidTest(void)(Derived*pd=newDerived;pd->f(10);//error)EF8-2-3ᵫ◚XÉÊ┯Ë

62ÌEF8-2-3Íᩭ◚{ᑣÏÐuÑ≶஺"◚ᑣÓ®ᨵÔÕÖᙠḄᳮᵫ♦ᑏ±²pd->f(10)Ḅ¹ØḄµ¶ᵨDerived::f(char*)ᦪÙÚË4#ᦪᑏ┯஺ᨵ◚ᑣÃÄᘤÜÁÝÞᢣ┯Ëßà$á}஺ᔲᑣÃÄᘤã☟ោោᙢ4┯Ü┯GHᕒ4uæçÕ┯ËèἪ᪷஺♦Ꮇ᝞DerivedᨵvÕ(v9ìí)ᨵ&î$ïðñòóôᦪõ᝞!Bᨵ◚ᑣö÷pd->f(10)¹ã¶ᵨÕÐ7ᧇḄᦪf஺ùú◚ᑣÍᩭ$û÷ᨵ⍝ᳮ"ýḄÞ¹þÿ᜜஺8-2-3᝞pd->f(10)⌕ᵨᦪBase::f(int),*+,-Derived1ᦋ3᝞4ᓽ6஺classDerived:publicBase(public:voidf(char*str);voidf(intx){Base::f(x);})B8.3CᦪḄEḕGᨵCᦪḄGᙠJKᦪᵨLMNOPᑏ᪵ḄSTUVW஺C++Z[ᵨCᦪḄEḕGTPᑏ\]^_(ᙠ`aLEḕGᵫ`aᘤdefᐭ)஺CᦪEḕGḄTᵨhᑣj•ூhᑣ8-3-1CᦪEḕGmnopᙠᦪḄqrstnopᙠuv஺᝞jvoidFoo(intx=0,inty=0);//{|EḕGopᙠᦪḄqrvoidFoo(intx=0,inty=0)//┯~EḕGopᙠᦪḄuv)3+S᪵ᡃᨵjᦪḄp(u)ᩭCᦪᔲᨵEḕGᐵᡠᨵ⌕EḕGopᙠᦪḄuv஺CᦪḄEḕG6nSᦋeᯠ1ᦋᦪḄqr1ᦋᦪḄu⌕஺•ூhᑣ8-3-2᝞ᦪᨵCᦪCᦪmnᔣᢸ¡Eḕᔲᑣ,¢£ᦪᵨ¤¥¤᪵஺{|Ḅ᝞4jvoidFoo(intx,inty=0,intz=0);

63┯~Ḅ᝞4jvoidFoo(intx=0,inty,intz=0);⌕§TᵨCᦪḄEḕG¨ᨵ©ªᦪ«Ḅ¬nTPᑏ\]^_஺®6nS¯°ᦪḄ᧕ᵨឋ³´6nSµ¶ᦪḄ6ᳮ¸ឋ஺ᡠᡃ¹mn〉»ᙢTᵨCᦪḄEḕG⌕■¾Tᵨt»¿ÀÁ☢ᦔ஺8-3-2tᔠᳮᙢTᵨCᦪḄEḕG,¢£ÅÆᦪoutput¿Àuឋ஺#includevoidoutput(intx);voidoutput(intx,floaty=0.0);voidoutput(intx)(cout<<"outputint஻<

64Complexoperator+(constComplex&a,constComplex&b);ÐÑÒßàᦪᙠᵨLḄtOáᜐjãäßàᦪCᦪopᙠᙊæçᑁBsãäÐÑÒCᦪopᙠᐸêஹìí஺᝞Complexa,b,c;c=Add(a,b);//ᵨßàᦪc=a+b;//ᵨÐÑÒ+᝞ÐÑÒîÅÆ3ᐰðᦪ*+mᨵCᦪḄÐÑÒÚÛᐗÐÑÒᨵCᦪḄÐÑÒÚÛᐗÐÑÒ஺᝞ÐÑÒîÅÆ3-Ḅᡂᕒᦪ*+ᐗÐÑÒᨵCᦪᐗÐÑÒmᨵìíCᦪ3ãôdõᡂöêíCᦪ஺÷ØøÐÑÒù6u3ᐰðᦪ´6u3ᡂᕒᦪ஺ᦻûüMurray,p44-p47⚪Ḅ▊⊤8-4TḄᑣ஺ᑣᡠᨵḄᐗ!"#ᡂᕒ&ᦪ=0(->+,#ᡂᕒ&ᦪ+=-=/-*=&21=ஹ2%=>>=<<=!"#ᡂᕒ&ᦪᡠᨵᐸ7!"#ᐰ9&ᦪ⊤8-4-1Ḅᑣᵫ;C++=>?ᢝ&ᦪA,BCᡂ&ᦪᩭᵨC=>FGH஺ᡃJ⌕LMNOᩭPᦟR(1)G⌕VᑖXOYZG[ᵨ7Ḅ\]^ᯠ`abᕒJc៉Ḅ&ᦪ஺(2)G⌕VᑖfOᙢhᵨ᝞j7G,hkṹmnop᧕r᧕ᑏtFuᵨᔲᑣ[Ywxy஺8.4.2G,zḄᙠC++|ᔠ~ᨵ`GᐕzḄ஺▲ᑴ`;ᐰ☢Ḅὃ⇋■┯஺(1)G,ᦋmC++ᑁᦪ(᝞int,float¢)Ḅ஺(2)G,£#ᙠ~¤¥ᡂᕒ¦ᨵ§¨©ªᡂ#᪗¬ᵨ஺(3)G,¯°C++|ᔠ~±ᨵḄ²᝞#,@,$¢஺¶£ᨵ·¸`¹Lᳮ»2`¹L¼½¾ᐜÀ஺(4)©ªÁᙠḄÂHÃG,ᦋm¾ᐜÀᑣᔲᑣBÄÅ஺8.5&ᦪᑁὶ8.5.1ᵨᑁὶÇkÈkṹ

65C++=>?ᢝ&ᦪᑁὶᐸ¯Ḅ`#ÉÊ&ᦪḄ᡻Hᦔ᳛(ÎÏ).ᙠCab~LᵨÈkṹÉÊ᡻Hᦔ᳛஺Èkṹ\ÑG`&ᦪÒhᵨÅᩭÓ&ᦪ஺⚜ᜐᳮᘤᵨ×ᑴÈkṹḄØkÙ&ᦪÚᵨḕÜÝᦪÞ᪘ஹàᡂáâ=>ḄCALLÚᵨஹãäÝᦪஹ᡻Hreturn¢VaåæÉÊÎÏ஺hᵨÈkṹᨬᜧḄé¸`ê᧕┯⚜ᜐᳮᘤᙠ×ᑴÈkṹÃNNëà§ìGᑮḄî▭ᦔð஺ñ᝞tfdefineMAX(a,b)(a)>(b)?(a):(b)=òresult=MAX(i,j)+2;Bz⚜ᜐᳮᘤ»ó#result=(i)>(j)?(i):(j)+2;ᵫ;'+'õ'R'Ḅ¾ᐜÀÊᡠLö=òG¢÷;øùḄresult=((i)>(j)?(i):(j))+2;᝞júÈkṹᦋᑏ#^defineMAX(a,b)((a)>(b)?(a):(b))ᑣL»ûᵫ¾ᐜÀÄÅḄ┯஺Ò`ᓽhhᵨýᦋþḄÈkṹÿᜫḄ᝞result=MAX(i++,j);⚜ᜐᳮᘤresult=(i++)>(j)?(i++):(j);C++ᵨṹᨵ!"#$%&'(Ḅ)ᨵᦪ+ᡂᕒ஺/ᡃ122C++Ḅ“4ᦪᑁὶ”᝞89'Ḅ஺:8ᑁὶ4ᦪ;<ᘤᙠ>?⊤ABᐭ4ᦪḄDE(ᒹHIJஹLᦪ(MஹNOP(M)஺᝞R;<ᘤSᨵTUᑁὶ4ᦪVᙠ┯XYZ[4ᦪḄṹ\Bᐭ>?⊤A஺ᙠ]ᵨ^ᑁὶ4ᦪ_;<ᘤ✌ᐜbc]ᵨᔲef(gh(Miᐰbcᡈὅghmn(MoᣚqᯠᡠᨵḄ4ᦪt᪵)஺᝞Refᑁὶ4ᦪḄṹvwxyzᣚ4ᦪ]ᵨḕ|}4ᦪ]ᵨḄ~├஺^⚜ᜐᳮᨵ℉Ḅ⚜ᜐᳮᘤgh(Miᐰbcᡈὅghmn(Moᣚ஺Ꮇ᝞ᑁὶ4ᦪᡂᕒ4ᦪḄᙢᙬ(this)wBᙠᔠ〉Ḅᙢ\⚜ᜐᳮᘤᑮḄ஺C++Ḅ4ᦪᑁὶᑴᐹᜓṹḄᦔ᳛}iᐰឋmᵫ&'(Ḅᦪ+ᡂᕒ஺ᡠᙠC++¡¢£[ᵨᑁὶ4ᦪ¤ᡠᨵṹ“¥assert”អ᝿¨Ḅ᜜஺assertªᙠDebug᱐¬'ᵨḄ®ᵨbc“£[”T¯Ḅ°±஺}ᙠ¡ḄDebug᱐¬²Release᱐¬³´µassert£[¶¯:8·'ᵨ஺᝞Rassert4ᦪᵫ4ᦪ]ᵨw³ᑁVஹṹḄ¸nYZ¹ºDebug᱐¬Release᱐¬Vᙠ´»஺ᡠassert4ᦪ஺(L¼6.5⁚“ᵨ¥”)8.5.2ᑁὶᦪḄᐵ¿JinlineÀÁ4ᦪÂÃÄBᙠÅ4ᦪᡂᑁὶªinlineBᙠ4ᦪDEÆ☢:8'ᵨ஺᝞ÈÉÊḄ4ᦪFooᡂᑁὶ4ᦪ$inlinevoidFoo(intx,inty);//inlineª4ᦪDEBᙠ

66voidFoo(intx,inty))᝞ÈÉÊḄ4ᦪFooᑣᡂᑁὶ4ᦪ$voidFoo(intx,inty);inlinevoidFoo(intx,inty)//iniine4ᦪÂÃÄBᙠ()ᡠÛinline!“ᵨÜUḄᐵ¿J”!“ᵨDEḄᐵ¿J”஺Ýᙢᵨᡝ▅à4ᦪḄDEá2ᑮ4ᦪḄÂÃ஺âãᙠᜧåᦪᦟçè¢ᑁὶ4ᦪḄDEஹÂÃÄÆ☢t}inlineᐵ¿Jáᡃéinline£[êUᙠ4ᦪḄDE¢஺^ë⁚ìᯠwíî4ᦪḄïáÄU}ðñòC++/C¡õöÉÊḄ^÷¬øᑣ$DEÂÃùúᵨᡝSᨵÀ⌕ஹ\£[ü⍝4ᦪᔲ◤⌕ᑁὶ஺ÂÃᙠ(DEÿḄᡂᕒᦪᙢᡂᑁὶᦪ᝞classA(public:voidFoo(intx,inty){…}//ᙢᡂᑁὶᦪ)ᡂᕒᦪḄ*+,-ᙠ/0123ᯠ56ᩭ8ᑏ:Ḅ;<=>?@ABCḄDEFG:HIᦋᡂK//ᜮᦻNclassA(public:voidFoo(intx,inty)O)//*+ᦻNiniinevoidA::Foo(intx,inty)(}8.5.3Uᵨᑁὶᑁὶ5WXᦪḄ᡻Zᦔ᳛]^>_ᡠᨵḄᦪb*+ᡂᑁὶᦪc᝞dᡠᨵḄᦪb?ᑁὶᦪeᵨfḼ“ᑁὶ”jkᐵmnᔩcᑁὶ?pqṹst(uᑴ)qwxxḕz{ᦪ|ᵨḄ}├WXᦪḄ

67᡻Zᦔ᳛஺᝞d᡻Zᦪ,ᑁqṹḄᦪ|ᵨḄ}├ᜧ^ᦔ᳛Ḅᦈ஺@;☢@ᜐᑁὶᦪḄ|ᵨb⌕uᑴqṹEḄqṹᜧ,ὑḄᑁ஺p¡>¢ᵨᑁὶK(1)᝞dᦪ,ᑁḄqṹ£ᵨᑁὶ¤¥ᑁὑqwX஺(2)᝞dᦪ,ᑁ¦§¨©^᡻Zᦪ,ᑁqṹḄ⌕ᦪ|ᵨḄ}├ᜧ஺/Ḅ᪀⌼ᦪ¬᪆᪀ᦪ®᧕°±²³ᡂᵨᑁὶᨵᦔ஺⌕´µ᪀⌼ᦪ¬᪆᪀ᦪ¶5◚¸@¹Z᝞“ᏕᏕᙢ”᡻Z{»/ᡈᡂᕒ½¾Ḅ᪀⌼ᦪ¬᪆᪀ᦪ஺ᡠp>⌕¿<ᙢ᪀⌼ᦪ¬᪆᪀ᦪḄ*+,-ᙠ/01஺@kCḄDÀᘤ᪷ÃᦪḄ*+,ᙢÄ>ÅfḄᑁὶ(jÆ@ÇÈ1Tinline>HI¦§ᙠᦪḄ01)஺8.6@¹µf,C++ÉÊḄËÌஹᑁὶஹÎḕÏᦪஹ◚ÐÑᣚÓÔᑴÕ§{Ö×=?j¹Ö×ḄØÙb◚¸Ḽ@¹◚Ú஺Û᝞±ÜḄÝÞÞ¬ßÞb>¶ÄH´ាᑮCᜐ஺ᡃÜ⌕ãäᙢåæC++ḄçÔᑴHIា᝞ᐸᑖᙢᵨêÜ஺3ᯠjᡃÜDEë@¹µì{@¹íî=jï?DEḄðñ஺

68ò9ó/Ḅ᪀⌼ᦪஹ᪆᪀ᦪôõÅᦪ᪀⌼ᦪஹ᪆᪀ᦪôõÅᦪ?k/ᨬ»ᩈḄᦪ஺êÜøùúp¥°±®᧕ûüᜧýᐸþj¹ÿᓫḄᦪᨵ⚔Ḅ⍝᪵ᓻ◅஺ᨵ᪆᪀ᦪᦪ!ᨵ"᪀⌼ᦪ(ᒹ&'(᪀⌼ᦪᐸ*Ḅ+,-.᪀⌼ᦪ)஺0123A,᝞89:;ᑏ=>ᦪC++;AᘤCDE,AFGHIḕḄᦪ᝞A(void);஻IḕḄQRᦪ᪀⌼ᦪA(constA&a);//IḕḄ'(᪀⌼ᦪ~A(void);஻IḕḄ᪆᪀ᦪA&operate=(constA&a);//IḕḄᦪ_9ἭabᶧdeᯠgDEGᡂᦪ,ijk⌕mnᕒ;ᑏpqr᝞s(1)᝞8uᵨ“IḕḄQRᦪ᪀⌼ᦪ”“IḕḄ᪆᪀ᦪ”y1z{|D}“~ᓄ”“◀”ḄC++bStroustrupḄ3|஺(2)“IḕḄ'(᪀⌼ᦪ”“IḕḄᦪ”ᙳᵨ“'(”“'(”Ḅᩭ᎚&ᨵᢣ┐_ᦪ¡C¢┯஺01¤ᨵᔛ¦§ᜮḄC++mnᕒ᝞8©ª;ᑏ᪀⌼ᦪஹ᪆᪀ᦪ¬ᦪ®᧕!9ᵨEᾯ±⊤©Ḅ³´kµ¶·¸¹ᨵº1»¼஺½¾!StringḄÀÁ¬,ÂÃᐭ▊>Æ"ᦟÈÉÊË|Ḅ⍝ᳮ஺StringḄÍ᪀᝞sclassString(public:String(constchar*str=NULL);//-.᪀⌼ᦪString(constStringfeother);//'(᪀⌼ᦪ~String(void);//᪆᪀ᦪString&operate=(constStringftother);//ᦪprivate:char*mdata;//ᵨ1ØÙÚÛÜ)Ý9.1᪀⌼ᦪ¬᪆᪀ᦪḄÞßà,µCáᐜãḄäåC++»æ|áḄᑴᩭèémnḄêᐰឋ஺C++;AᘤᐹᨵîïḄðêᐰñòóg*ôõgö¢mnᡠᨵḄäøù⚪_Ḅûürmn

69ᕒḄᜧþ஺ÿ⊤┯ᙠᙠ“┯”Ḅᜧ“┯”Ḅᙢ!"#$$஺&'(Ḅ┯)◚+,-./012Ḅ3456789:᧕஺᪷=>?@ABCḄ┯"ᵫEFGHᨵJKLMNᓄᡈQ◀⌼ᡂḄUMNᓄVQ◀WX-:᧕JY⍡[஺Stroustrupᙠ\]C++^_ᐙᑖὃ⇋def⚪-hᙢiAjklmn0ḄMNᓄWXoᙠ᪀⌼qᦪsmQ◀WXoᙠ᪆᪀qᦪs஺un0Jvw_᪀⌼qᦪJxy᡻{.un0}~_᪆᪀qᦪJxy᡻{஺d/ᵨ[n0ḄMNᓄVQ◀WX஺᪀⌼qᦪ᪆᪀qᦪḄᘤ,9AJxy᡻{஺StroustrupḄᓫᔠᳮl᪀⌼qᦪஹ᪆᪀qᦪᵫE᪆᪀qᦪḄḄ᪀⌼qᦪḄ/A¡'஺◀᜜᪀⌼qᦪ᪆᪀qᦪḄ£¤eᱯ'¦ᜐ"Hᨵ¨©ª«d¨©ª«¬voidḄqᦪ஺᪀⌼qᦪ᪆᪀qᦪḄ®)¯L/0°±~ᐝ³³ᙢᩭᐝ³³ᙢµ஺᝞·¸¹ᨵ¨©ª«º»ᘤ¼½ᡠ¿஺¬■Á⁚᜜°ÃÄᾪÆÇHᨵ¨©ª«஺(AÉᐺᦑÌὃᦻÎlEekel,p55-p56J)9.2᪀⌼qᦪḄMNᓄ⊤᪀⌼qᦪᨵeᱯÏḄMNᓄÐÑ“MNᓄ⊤ÒÐ⊤”(ÓMNᓄ⊤)஺MNᓄ⊤EqᦪÌᦪ⊤¦Õᓾᙠqᦪ×(}¦஺dÙ¯Ú⊤ḄMNᓄWXÛ°ᙠqᦪ×ᑁḄÝÞßṹJ᡻{¦஺᪀⌼qᦪMNᓄ⊤ḄᵨÆᑣl♦᝞·ᙠâãᐵåæ°ᙠᐸMNᓄ⊤èᵨéḄ᪀⌼qᦪ஺ê᝞classA{...A(intx);//AḄ᪀⌼qᦪ)ìclassB:publicA!...B(intx,inty);//BḄ᪀⌼qᦪ)ìB::B(intx,inty):A(x)//ᙠMNᓄ⊤èᵨAḄ᪀⌼qᦪ)♦Ḅconst)GᙠMNᓄ⊤JMNᓄð¬¸ᙠqᦪ×ᑁᵨñªḄÐᩭMNᓄ(Ìò5.4⁚)஺

70♦Ḅᦪ=ᡂᕒḄMNᓄ9AôᵨMNᓄ⊤ᡈqᦪ×ᑁñªõöÐdõöÐḄᦔ᳛ùᐰ஺®ᑁûᦪ=«Ḅᡂᕒn0üuôᵨý¤öÐMNᓄAþÿḄᦔ᳛஺᝞classA{...A(void);//ᦪ᪀⌼ᦪA(constA&other);//$%᪀⌼ᦪA&operate=(constA&other);//()ᦪ);classB(public:B(constA&a);//BḄ᪀⌼ᦪprivate:Am_a;//ᡂᕒ23)459-2(a)9:;BḄ᪀⌼ᦪᙠᐸ>?ᓄ⊤BCᵨE;AḄ$%᪀⌼ᦪ:FGHᡂᕒ23m_a>?ᓄ஺59-2(b)9:;BḄ᪀⌼ᦪᙠᦪIᑁᵨ()ḄKLHᡂᕒ23m_a>?ᓄ஺ᡃNOᑮḄQRSᩩ()UV:WX▭ZBḄ᪀⌼ᦪ[E\]^_ᐜᨩᙢBcdma23(CᵨEAḄᦪ᪀⌼ᦪ):eCᵨ;AḄ()ᦪ:Hᦪa(fB::B(constA&a)B::B(constA&a):m_a(a)({m_a=a;))59-2(a)ᡂᕒ23ᙠ>?ᓄ⊤9g>?ᓄ59-2(b)ᡂᕒ23ᙠᦪIᑁg>?ᓄ2hᑁiᦪj;kḄᦪjᡂᕒGl:\m>?ᓄKLḄᦔ᳛nopᨵrs:WtὅḄvw᱐Lyozᨎ|஺};FḄ᝞_classF(public:F(intx,inty);//᪀⌼ᦪprivate:intm_x,m_y;intm_i,m_j;

71)59-2(c)9FḄ᪀⌼ᦪᵨESm>?ᓄKL:59-2(d)9FḄ᪀⌼ᦪᵨEm>?ᓄKL஺F::F(intx,inty)F::F(intx,inty):m_x(x),m_y(y)((m_x=x;m_i=0;m_yy;m_j=0;m_i=0;)m_j=0;)59-2(c)ᦪjᡂᕒᙠ>?ᓄ⊤9g>?ᓄ59-2(d)ᦪjᡂᕒᙠᦪIᑁg>?ᓄ9.3᪀⌼᪆᪀Ḅw᪀⌼F;Ḅᨬ᪷ᜐ?:ᙠS9:✌ᐜCᵨ;Ḅ᪀⌼ᦪ:ᯠtCᵨᡂᕒ23Ḅ᪀⌼ᦪ஺᪆᪀ᑣᢥ᯿᪀⌼Ḅw᡻:wR¡SḄ:ᔲᑣ£¤ᘤH¦§¨᡻᪆᪀©v஺Sªᨵ«Ḅ¬3R:ᡂᕒ23>?ᓄḄwᐰ¯°±Nᙠ>?ᓄ⊤9wḄ²³:Qᵫᡂᕒ23ᙠ;9Ḅwµ¶஺·R¸¹;ḄR¡SḄ:G;Ḅ᪀⌼ᦪº»ᨵ¼ª:¸½¾ᨵ¼ª¯¿wḄ>?ᓄ⊤஺᝞Àᡂᕒ23ᢥ᯿>?ᓄ⊤ḄwÁ᪀⌼,·HÂÃ᪆᪀ᦪ¦Äᑮ¡SḄ⌮w஺[Eckel,p260-261]9.45_;StringḄ᪀⌼ᦪ᪆᪀ᦪ//StringḄÎÏ᪀⌼ᦪString::String(constchar*str)(if(str==NULL)(mdata=newchar[1];*m_data=:\0';)elseintlength=strlen(str);m_data=newchar[length+1];strcpy(m_data,str);

72)//StringḄ᪆᪀ᦪString:ÙString(void)delete[]m_data;//ᵫhm_dataRᑁiᦪj;k:Úº»ᑏᡂdeletem_data;9.5¯⌕ÝÞ$%᪀⌼ᦪ()ᦪᵫhßàᡠᨵḄ23â¾ãᵨ$%᪀⌼ᦪ()ᦪ:vwᕒºä2·\ªᦪᨵ|ÝÞ஺åᐜæç»Ḅèé:ᙠ▅ëìᦻîï¾¼ð_♦ñòᜮô©:᝞À¯õ¨£ᑏ$%᪀⌼ᦪ()ᦪ:£¤ᘤH»“÷$%”ḄKL§¨ùᡂúḕḄᦪ஺᎚};9ýᨵᢣ┐ḕḄᦪ◚┯஺StringḄa,b"#Ꮇ%a.mdataḄᑁ*"“hello”b.m_dataḄᑁ*""world"஺45a67b,ḕ68ᦪḄ“9:;”<ᕡḼ᡻@b.m_data=a.m_data஺5⌼ᡂD┯EFGb.mdataHᨵḄᑁJKLMN⌼ᡂᑁJO☄QRGb.m_dataSa.m_dataᢣᔣV•ᙽᑁJaᡈbZ[F\]^_`abF\QDGᙠL᪆᪀fm_dataLMNg஺♦:;᪀⌼ᦪS68ᦪhi*᧕klimn┯ᑏஹ┯ᵨ஺:;᪀⌼ᦪGᙠLrsftᵨḄu68ᦪvwLxyJᙠḄtᵨ஺z{|}~DS~ᑖtᵨ:;᪀⌼ᦪtᵨ68ᦪᔩStringa("hello");Stringb("world");Stringc=a;஻tᵨ:;᪀⌼ᦪᨬᑏᡂc(a);c=b;஻tᵨ68ᦪ#}~DḄᦋᑏᡂStringc(a)~஺9.6#EStringḄ:;᪀⌼ᦪ68ᦪ//:;᪀⌼ᦪString::String(constString&other)

73//ᐕ¥¦§otherḄ¨ᨵᡂᕒm_dataintlength=strlen(other,mdata);m_data=newchar[length+1];strcpy(mdata,other,mdata);)//68ᦪString&String::operate=(constString&other)(//(1)°±²68if(this==&other)return*this;//(2)MNHᨵḄᑁJ·¸delete[]mdata;//(3)ᑖº»ḄᑁJ·¸¼½ᑴᑁ*intlength=strlen(other,mdata);mdata=newchar[length+11;strcpy(m_data,other.m_data);//(4)ÀÁḄÂᵨreturn*this;)String:;᪀⌼ᦪÃÄ᪀⌼ᦪ(ÅÆ9.4⁚)ḄGEᙠᦪᐭÊᜐÌ◤NULLÑ@ÒGÓ"“Âᵨ”ÔÕwGNULL,u“ᢣ┐”Õ"NULL஺StringḄ68ᦪÒ᪀⌼ᦪ½ᩖØᑖÙÚ4E(1)~FÙ°±²68஺Õw_Û"ØÜFÝÞ⍝ᨵà_á≶ᑮᑏäa=a᪵Ḅ²68æḄçÔ_஺èGéêḄ²68ëᨵÕwä4#᝞//ᑁ*²68//ᙢᙬ²68b=a;b=&a;c=b;aR*b;a=c;ï¥ᨵà_ðE“ᓽòä4²68ᡃïÕÔᳮõᜧÔᓄøféù½ᑴ²úuxûüÔ_ä┯æ”

74ýþḄð┯஺ÿḄdelete,ᩔᑴᔩᡠ᝞!"#ᦪ஺&'(⌕*+,Ḅif/0if(this==&other)┯ᑏᡂ=if(*this==other)(2)ᵨdeleteABCᨵḄᑁFGH஺᝞ᙠ(ABJKLMN*⌼ᡂᑁFP☄஺(3)SᑖUVḄᑁFGHWᑴXYZ஺&'#ᦪstrlen\]Ḅ^ᨵᦔXYZ`a(ᒹcdeY'\0'஺#ᦪstrcpyᑣm(\0,noᑴ஺(4)q\]rstḄuᵨvḄ^=Nwta=b=cz᪵Ḅ|}⊤஺&'(⌕*return*this┯ᑏᡂreturnthis஺ᔲᑏᡂreturnotherᕖᦔ(^n᪵ᔩ(=ᡃ(⍝ᦪotherḄ஺ᨵother^stᙠdeᜫreturn0ther\]Ḅ*^ᚗ஺9.7ᏕḄᜐᳮ᪀⌼#ᦪ¡#ᦪ᝞ᡃwᙠ(¢£ᑏ᪀⌼#ᦪ¤#ᦪ¥(ᐕ§¨©ªᵨ£«ᘤᡂḄḕ#ᦪ¯ᏕḄ^°±◤*᪀⌼#ᦪ¤#ᦪ³´=µᨵ#ᦪ(ᵨ£ᑏ¶ṹ஺¸᝞°classA{...private:A(constA&a);//µᨵḄ᪀⌼#ᦪA&operate=(constA&a);//µᨵḄ#ᦪ)À᝞ᨵ©Á£ᑏ᝞ÃÄÅ°Ab(a);஻ÇᵨNµᨵḄ᪀⌼#ᦪb=a;//ÇᵨNµᨵḄ#ᦪ£«ᘤ*ᢣÉ┯Ê=᜜Ì(ÍÎAḄµᨵ#ᦪ஺9.8᝞ÏᙠÐÑÒwÑḄÓr#ᦪÓÑḄ᪀⌼#ᦪஹ᪆᪀#ᦪஹ#ᦪÖ(×ÐÑØÙ஺᝞ÑÚÛFᙠØÙᐵÝᙠ£ᑏÞÓr#ᦪ&'Ãß⚗°♦ÐÑḄ᪀⌼#ᦪᙠᐸâãᓄ⊤åÇᵨÓÑḄ᪀⌼#ᦪ஺

75♦ÓÑ¡ÐÑḄ᪆᪀#ᦪ=æ(ᓽèvirtualᐵéX)஺¸᝞#includeclassBase{public:virtual'Base(){cout<<"ðBase”<

76Derived&operate=(constDerived&other);//ÑDerivedḄ#ᦪprivate:intm_x,m_y,m_z;)Derived&Derived::operate=(constDerivedMother)(//(1)!"if(this==&other)return*this;//(2)'()Ḅᦪ,ᡂᕒ/0!"Base::operate=(other);//23456789:ᨵᦪ,ᡂᕒ//(3)'=>)Ḅᦪ,ᡂᕒ!"m_x=other.m_x;m_y=other.m_y;m_z=other.m_z;//(4)BCD'EḄFᵨreturn*this;)9.9HIJKLMᨵIC++PQRSTUV᪀⌼Yᦪஹ᪆᪀Yᦪ\!"Yᦪ])Ḅ“Big-Three”cdeḄf]gh)ᨬ/⌕ḄYᦪc4klm஺opqr3DsḄᑁkuvwxyczMy{5|}~cᡃ459஺᝞qᔛ“Big-Three”c▅ὃᦻ[Cline][Meyers][Murry]஺

7710s)Ḅᔠ'E(Object)])(Class)ḄH(Instance)<>᝞'E9¡c¢£){]¡ḄRS¤¥஺ᡠ§☢ᔣ'ERSḄ/ª])ḄRSc«4]'EḄRS஺'¬C++PQ«cRS®¯Ḅ)]°k᧕Ḅc²Ḅ]³fRS()´ᐸ=>)஺Ds¶¶·¸“”(Inheritance)\“ᔠ”(Composition)Ḅᭆº஺»¼c½¾☢ᔣ'EᢈÀḄÁᵨª]COM\CORBA,IᑁkÃÄyC++ᦟᩞḄᶖc▅COM\CORBAÉᐵ·℉஺10.1᝞A]()cB]AḄ=>)c¢£BAḄᦪ,\Yᦪ஺᝞ÌclassA(public:voidFuncI(void);voidFunc2(void);)AclassB:publicA(public:voidFunc3(void);voidFunc4(void);)Amain()(Bb;b.Funcl();஻BÎAyYᦪFunclb.Func2();஻BÎAyYᦪFunc2b.Func3();b.Func4();}ÏᓫḄÑPQÒÓyHÌC++Ḅ“”ᱯឋÖ§×ØPQḄÖÙᵨឋ஺³23“”ÚᨵᵨஹÚk᧕ᵨcÛ⌕■ÝÞᵨ“”஺ᡃeÁ½ß“”¯

78HIàᵨáᑣ஺•ூáᑣ10-1-11᝞)A\)Bå4Éᐵc4Ö§3yàBḄæ5çxI«èBAḄæ5\éឋ஺4⌕êK“ëᔛë4ᔛ”cèHììḄᏉî☘ð~ñ~ᦑᙢᔛô⊡öL஺•ூá÷!|10-1-21úᙠüýþB]AḄ“Hÿ"(akindof),ᑣᐕBAḄឋ஺᝞ᵱ(Man)(Human)Ḅᵱ(Boy)ᵱḄ-஺ManHumanBoyMan஺classHuman()AclassMan:publicHuman()AclassBoy:publicMan♦!"⚗ூ%ᑣ10-1-21&'ᩭ)*ᓫ,-▭/ᵨ12ᨵ!᜜Ḅᭆ6ᙠ89:;<=-:;>?@ᐰBC஺᝞ᱥEFGHIJ(Ostrich)J(Bird)Ḅ,ᢥᳮNOstrich/OBird஺,IJ?POstrich::FlyQRSTclassBird(public:virtualvoidFly(void););classOstrich:publicBird);᝞ᦪEFGHᙊ(Circle)ᱯZḄ[ᙊ(Ellipse),ᢥᳮNCircle/OEllipse஺,[ᙊᨵ\]^]᝞_ᙊ`[ᙊḄ\]ᑭ^]b

79defghTᡠjklmḄ%ᑣ/nopᙠqrsBAḄ“”>vAḄᡠᨵឋwBxyzᨵ!{ᑣᐕBAḄឋ஺10.2|ᔠ•ூ%ᑣ1021௃pᙠqrsABḄ“ᑖ”(apartof),ᑣ?ᐕBAx⌕ᵨAᐸRS|ᔠBo᝞(Eye)ஹ(Nose)ஹU(Mouth),ὡ(Ear)ᜮ(Head)ḄᑖᡠHead/OᵫEyeஹNoseஹMouthஹEar|ᔠxᡂ?xᡂ஺᝞10-2-1ᡠOclassEyeclassNose((public:public:voidLook(void);voidSmell(void);))classMouthclassEar((public:public:voidEat(void);voidListen(void);););//Ḅᯠṹᑍ\஺classHead(public:voidLook(void){m_eye.Look();}voidSmell(void){m_nose.Smell();}voidEat(void){m_mouth.Eat();}voidListen(void){m_ear.Listen();}private:Eyem_eye;Nosem_nose;Mouthm_mouth;Earm_ear;)10-2-1HeadᵫEyeஹNoseஹMouth>Ear|ᔠxᡂ᝞_ᐕHeadEyeஹNose>MouthஹEarxᡂHeadᐹᨵLookஹ

80SmellஹEatஹListen஺10-2-2ᓝᑖ*^>v¡,¢£ᓾ?wḄ஺//>vṹ*¥,¢£?w஺classHead:publicEye,publicNose,publicMouth,publicEar(¦___________________________________________________________________________________________10-2-2HeadEyeஹNoseஹMouthஹEarxᡂ¨©ª«¬ᙢ®ᡭ¨°±`²Ḅ³ª´µ⍝·QᔩT¹·³ª±`º²஺)»89ᕒ½?'“”Ḅ¾¿xÀ±┯Â஺“¡”Ḅ89?ÃÄÅÆÇḄ89ÈᜐÊËÌ஺

81ÍUÎᐸÏ8½Ð11.1«ᵨconstÑÅÒᦪḄᏉÔឋ&ᑮconstᐵ×ØC++89ᕒ✌ᐜÛᑮḄconstÜÇ.?ÞßḄᩩáâã஺᝞_¨µ⍝ᵨconstä{ÜÇBnåæçèéᵨåᑴëìí஺constjᜧḄïðñ⛲ÒᦪḄóᦪஹôõö÷øÒᦪḄä{ù஺constconstantḄúᑏ“ឤä?ý”Ḅ!þ஺ÿconst⛲Ḅᑮᑴ⚜■᜜ḄḄᏉឋ஺ᡠC++!"#$%&:“Useconstwheneveryouneed”஺11.1.1ᵨconstc⛲ᦪḄoᦪ᝞)*ᦪ,-.ᵨ012345ᦪ6789012:ᵨ“ᢣ┐>⌴”A3“Bᵨ>⌴”0Cconst⛲ᔲᑣF*ᦪGᜫI-.J஺constK⛲-ᐭ*ᦪM♦᝞)-ᐭ*ᦪ:ᵨ“ᢣ┐>⌴”O5Cconst⛲■P᜜ᙢᦋFᢣ┐Sᑮ,ᵨ஺T᝞StringCopyUᦪMvoidStringCopy(char*strDestination,constchar*strSource);ᐸWstrSource3-ᐭ*ᦪstrDestination3-.*ᦪ஺XstrSourceCYconst⛲Z᝞)Uᦪ[ᑁḄ]^_`ᦋstrSourceḄᑁabcᘤGᢣ.┯f஺♦᝞)-ᐭ*ᦪ:ᵨ“g>⌴”ᵫiUᦪGjklmnoᵨipᑴF*ᦪF-ᐭ*ᦪqᩭst◤ᡠ0⌕Cconst⛲஺T᝞0⌕GUᦪvoidFund(intx)ᑏᡂvoidFund(constintx)஺yᳮ0⌕GUᦪvoidFunc2(Aa)ᑏᡂvoidFunc2(constAa)஺ᐸWA{ᵨᡝj}~Ḅᦪ678஺♦iᑁᦪ678Ḅ*ᦪvoidFunc(Aa)᪵ḄUᦪ}ᦔ᳛஺{Uᦪ[ᑁGklA78Ḅmnᵨipᑴ*ᦪa,mnḄ᪀⌼ஹpᑴஹ᪆᪀Gὑn஺{ᦔ᳛GUᦪᦋ{voidFunc(A&a),{“Bᵨ>⌴”ᵨ*ᦪḄ0◤⌕klmn஺3UᦪvoidFunc(A&a)¡ᙠ•¤¥¦M“Bᵨ>⌴”ᨵᦋ*ᦪa,3ᡃ©0ª«Ḅ஺¬¤®⚪a᧕Cconst⛲ᓽ²Uᦪᨬ´ᡂ{voidFunc(constA&a)஺²7µ3ᔲ¶GvoidFunc(intx)ᦋᑏ{voidFunc(constint&x),·ᦔ᳛¸¹ᐰ»ᨵ¼⌕{ᑁᦪ678Ḅ*ᦪ0¡ᙠ᪀⌼ஹ᪆᪀Ḅpᑴ9½¾''g>⌴”À“Bᵨ>⌴”Ḅᦔ᳛ÁÂÃÄ஺®⚪3᝞²ḄÅÆᡃKÇG“const&”⛲-ᐭ*ᦪḄᵨÉÊË᝞⊤11-1-1

82ᡠÍ஺iᑁᦪ678Ḅ-ᐭ*ᦪ¶FG“g>⌴”ḄÎÏᦋ{“constBᵨ>⌴”ÕḄ3ᦔ᳛஺T᝞GvoidFunc(Aa)ᦋ{voidFunc(constA&a)஺iᑁᦪ678Ḅ-ᐭ*ᦪ0⌕G“g>⌴”ḄÎÏᦋ{“constBᵨ>⌴”஺ᔲᑣßà0ᑮᦔ᳛ḄÕḄáâãUᦪḄᳮ¬ឋ஺T᝞voidFunc(intx)0¶Fᦋ{voidFunc(constint&x)஺⊤11-1-1"const&”⛲-ᐭ*ᦪḄèᑣ11.1.2ᵨconst⛲UᦪḄëìg♦᝞)X“ᢣ┐>⌴”ÎÏḄUᦪëìgCconst⛲O5Uᦪëìg(ᓽᢣ┐)Ḅᑁa0íᦋFëìgKíîXCconst⛲Ḅy78ᢣ┐஺T᝞Uᦪconstchar*GetString(void);᝞]^G.÷bc┯fMchar*str=GetString();ùúḄᵨÉ3constchar*str=GetStringO;♦᝞)Uᦪëìg:ᵨ“g>⌴ÎÏ”ᵫiUᦪüýëìgpᑴᑮ᜜mnḄ¡þᓫᐗconst⛲ᨵ஺᝞᝞ᦪintGetlnt(void)ᑏᡂconstintGetlnt(void)0$ᳮ⌕ᦪAGetA(void)ᑏᡂconstAGetA(void),ᐸA*ᵨᡝ-./Ḅᦪ123஺᝞4567ᑁ9ᦪ123:ᦪAGetA(void)ᦋᑏ*constA&GetA(void)Ḅ=>?@ᦔ᳛஺CDEᓟGᓟG⌕HIJ.⌕KLMᦪNO7P56JQRSḄ“UV”X7Y56“Z[”\]^_ᔲᑣbcde┯஺g6.2⁚“56Ḅlᑣ”஺♦ᦪ56mᵨ“nᵨo⌴”Ḅqᔠstuvwx•z{e|ᙠ2Ḅ~ᦪḄ7*_|x⊤஺᝞classA(-A&operate=(constA&other);//~ᦪ)Aa,b,c;//a,b,c*AḄRSa=b=c;//Ḅx~

83(a=b)=c;//Ḅx~Cᔠᑴ(JQConstRSᑴ)᝞4:~ᦪḄ56const⛲56Ḅᑁᐕᦋ஺¡.¢£a=b=c¤ᯠ=C7¢£(a=b)=cᑣ7¦Ḅ஺11.1.3constᡂᕒᦪdᦋᦪ1ᡂᕒḄᦪ¨©ª«*const23஺᝞4ᙠ¬ᑏconstᡂᕒᦪEᦋ_ᦪ1ᡂᕒᡈὅ°ᵨ_ᐸ±¦constᡂᕒᦪ¬²ᘤ:ᢣe┯µu¶ᶧd?@bcḄᏉ¹ឋ஺^»bc2stackḄᡂᕒᦪGetCountYᵨ¼ᦪ½¾¿ÀÁGetCount©*constᦪ஺¬²ᘤ:ᢣeGetCountᦪḄ┯µ஺classStack(public:voidPush(intelem);intPop(void);intGetCount(void)const;//constᡂᕒᦪprivate:intm_num;intm_data[100];)intStack::GetCount(void)const(++m_num;//¬²┯µÂÃᦋᦪ1ᡂᕒm_numPop();஻¬²┯µÂðᵨ¦constᦪreturnm_num;)constᡂᕒᦪḄª«ÅÆᩭÈÈḄÉconstᐵËÌ{>Íᙠᦪª«ḄÎ9ᜧᭆ7Ñ*ᐸ±ᙢw¨ÓÔᓰᵨ_஺11.2?@bcḄᦔ᳛bcḄEÖᦔ᳛7ᢣ×ØÙÚÛÖᦔ᳛7ᢣbcᓰᵨᑁÜᡈὅ᜜ÜḄÞß஺ᐰᕜᦔ᳛7ᢣâᙠ᦮QäåḄæÚÀὃ⇋Ḅᦔ᳛é9ᦔ᳛7ᢣâᙠêᙽᡈᦪæÚÀὃ⇋Ḅᦔ᳛஺ூlᑣ11-2-1]⌕JᕡᙢîïbcḄᦔ᳛©ᙠðñ=ឋஹ]☠ឋஹᏉ¹ឋஹ]ôឋõö÷ÑøḄù?»ú?@bcḄᦔ᳛஺

84•ூlᑣ11-2-2^?@bcḄᐰéᦔ᳛*û?@é9ᦔ᳛*ü஺•ூlᑣ11-2-3ᙠýᓄbcḄᦔ᳛E©ᐜ▲ᑴᦔ᳛Ḅ“⚠”⌕ᙠᐵ⌕ᜐᓄ஺•ூᑣ11-2-4ᐜᓄᦪ᪀!"#$ᓄ᡻&'ṹ஺•ூᑣH-2-51ᨵ*᎛*,ᦔ᳛!-,ᦔ᳛./012*34ᑖ᪆789:⌕;〉4Ḅᢚ⊭஺?᝞ABCDEᑁGᩭIJឋ/஺•ூᑣ11-2-6௃⌕MNOḄ'ṹPQOḄ'ṹR/STJᦔḄUᘤṹ஺11.3DEᨵWḄXYZூXY11-3-1௃4[7E\]^᧕ᑖ`Ḅa;bcTdᑏ┯g஺ᡃijklm“==”gᑏᡂ“="q'"ஹ“&&”ஹ“<="ஹ">=”wxbyz{|᧕cT“}1”ᜫg஺ᯠᘤᓾD/ᢣwx┯g஺ZூXY11-3-2ᢣ┐ஹᦪX34*miᓄ■mᓄḄ4ᡂᵨ஺ZூXY11-3-3௃4[Ḅஹḕ┯gᡈὅ¡¢£஺ZூXY11-3-44[ᦪx¤¥ᣚcT┯g஺§ᵨ¨©Ḅᦪx¤¥ᣚª«i¬⍝cT®¯°±²³ªᘤ´ោោᙢ·&◚©Ḅᦪx¤¥ᣚ஺ZூXY11-3-5௃4[cT^¹ᡈº¹ᦪḄº᪗¼½஺ZூXY11-3-6௃4[¾¿ᑏ┯gᜐᳮÁÂ4[┯gᜐᳮÁÂÃÄᨵg஺ZூXY11-3-74[ᦻÆ1/0ᨵ┯g஺ZூXY11-3-8²³ᑏᢈÈឋ{J'ṹ஺ZூXY11-3-9⌕ÉÊ☢☢ÌᑮஹÎkᮣÐḄᦪ᪀஺ZூXY11-3-10᝞ÑÒᨵḄ'ṹÓÔÕÖ§×ᵨ஺ØÙ⌕Ú⊡{ÜÝḄ

85'ṹ34:Þᑏ஺ZூCD11-3-111§ᵨ᪗ßàáᦪ⌕“câ”ãjGᙠḄàáᦪ஺ZூCD11-3-121§⌕ᵨäᐹæçÆᡈèÆé᛻ᐵëìᑗḄ஺ZூCD11-3-13௃mᘤḄ⌱ï⚗ÉñQᨬóôõ᝱஺ZூCD11-3-141᝞Ñ./Ḅ÷ᵨPC-LintஹLogiScopeøùᐹ·&'ṹúû஺

86üὃᦻþ[Cline]MarshallP.ClineandGregA.Lomow,C++FAQs,Addison-Wesley,1995[Eckel]BruceEckel,ThinkinginC++C++Áÿᑢᵪ᱐,2000[Maguire]SteveMaguire,WritingCleanCode☟ᵯ᱐1993[Meyers]ScottMeyers,EffectiveC++,Addison-Wesley,1992[Murry]RobertB.Murry,C++StrategiesandTactics,Addison-Wesley,1993[Summit]SteveSummit,CProgrammingFAQs,Addison-Wesley,1996

87▬AC++/Cṹ!⊤ᦻF᪀#⌕ឋ!⚗'(ᜮᦻ+,-.ᦻ+Ḅ012ᔲᔠᳮ6ᜮᦻ+,-.ᦻ+Ḅ7'᪀2ᔲᔠᳮ6᱐ᩗ,᱐:;<2ᔲ=᦮6G⌕ᜮᦻ+2ᔲ?ᵨAifndef/define/endif⚜ᜐᳮᙽ6ᜮᦻ+E2ᔲFGH“;<”KLGH"-.”...IJḄ᱐(#⌕ឋ!⚗'(OP2ᔲQR6ṹPᑁḄOT2ᔲQR6UPVᑖ2ᔲQR6“{”,“}”2ᔲᔜᓰ\P]^_`ab\ᑡ6G⌕\Pṹ2ᔲFd\+e6᝞F-.\ghiFᑏ\ᩩlm஺G⌕If\forஹwhile>dolmpᓰ•PL(᡻Plmstu⌕v“{}VG⌕ᙠ-.hiᡈyᦪ{2ᔲ|}⛲*,&☠hi062ᔲᨎ]^⌕6G⌕2ᔲᨵ┯ᡈὅ6G⌕'᪀Ḅpublic,protected,private2ᔲᙠᡠᨵḄEᢝ\6....KLMᑣ#⌕ឋ!⚗'(G⌕0ᑣ2ᔲᡠᵨḄᡈ¡¢ᐹḄ¤Tᢝ\6᪗¦2ᔲ§¨^©ª«6᪗¦ḄU¬®ᔠ“min-length&&max-informationw¯ᑣ6G⌕E2ᔲ°±bḄ²³hi,ᐰ³hi60ஹµᦪ0ஹhi,yᦪஹ¶iḄ·ᑏT¸2ᔲ⍳º\-Ḅᑣ6☟᝱hiஹᐰ²hiஹḄᡂᕒhi2ᔲv¾¿6

88⊤O(PQRST#⌕ឋ!⚗'(G⌕᝞ÀṹPEḄÁÂÃÄs2ᔲÅÆᵨÇÈÉᙢË-⊤̸Ḅ62ᔲᑏÍÎᩖᡈὅsᵨ⌶ḄÎᔠ⊤̸6#⌕2ᔲ|Îᔠ⊤̸“ÑÒḄᦪÓ⊤̸”ÔÕ6G⌕2ᔲᵨ◚×┯Ḅظᑏiflm6Ù᝞(1)|ÚÛhi§ÜTRUEஹFALSEᡈὅ1ஹ0ÝPÃÄ஺(2)|Þßhiᵨ“=="ᡈ"á=”âãᦪäÃÄ஺(3)|ᢣ┐hiᵨ“=="ᡈ"á=”NULLÃÄ஺᝞ÀºçRᑁGᙠèéᑨë]^ºçìᦪíᜧ2ᔲÅÆ|èéᑨëïᑮºçRḄ᜜☢6G⌕CaselmḄ'ó2ᔲôAvbreak?G⌕2ᔲôõᑏswitchḄdefaultᑖö6G⌕?ᵨgotolm{2ᔲᶇø◚ù6Ù᝞úûAüý_þḄ᪀⌼ஹḄᓄஹ⌕Ḅ஺....UV⌕ឋ⚗ᔲᵨḄᩭ⊤!"ᙠ$%&'()*Ḅᦪ,ᡈ,./0ᙠC++$%&1ᔲᵨconst2340⌕᝞6789ᐸ;<ᑗ>ᐵ1ᔲᙠ@&ᒹBCDᐵE0ᔲFGBH&ḄconstᦪIᡂᕒ0LMconstᦪIᡂᕒNᙠ7OPQRSTᑁ1VPW᦮OHVYᓾ[Ḅ஺...\ᦪ]⌕ឋ⚗^ᦪḄ_ᑏᔲa᦮0b⌕cdḕfNᑏ^ᦪḄHgVḕᶍ^ᦪi,஺^ᦪjiஹk%ᔲᔠᳮ0^ᦪḄOᦪᔲn'0ᔲᵨHgoᦪpbq@Ḅ^ᦪ0ᔲḕᶍB\ᦪrstḄHg0\ᦪi,9rstHgᙠuvᔲwx0

89G⌕ᔲ"zto┯F᪗}~ᙠrs0ztᵨ)^ᦪ1V┯F᪗}ᵨreiurnurs஺G⌕ᙠ\ᦪḄ“ᐭᜐ”1ᔲᵨassertP^ᦪḄᨵᦔឋ0G⌕ᵨᵨBassert?᝞~9┯F1ὅᯠSᙠḄ8@⌕)ᜐᳮḄ஺G⌕returnuᔲrsᢣᔣ“᪘ᑁS”Ḅ“ᢣ┐”ᡈὅ“£ᵨ110ᔲᵨconst¤¥\ᦪḄᏉ§ឋ0const[¨©ᑴ«¬\ᦪḄ^ᦪஹrst1®\ᦪḄ@¯Useconstwheneveryouneed”...ᑁ5Wᳮ⌕ឋ⚗G⌕ᵨmallocᡈnewᵭ±ᑁS²1ᔲ³ᓽᢣ┐tᔲMNULL?µ■·ᵨᢣ┐tMNULLḄᑁS¸G⌕ᔲ¹ºMᦪ»o¼᝱ᑁS¾t0µ■·"¿ÀᓄḄᑁSMÁtᵨ¸G⌕ᦪ»ᡈᢣ┐ḄÂ᪗ᔲÃÄ0G⌕¼᝱ᑁSḄᵭ±9ÅÆᔲÇP0µ■·ᑁSÈɸG⌕ᔲᨵᦔᙢᜐᳮB“ᑁSὑÌ”Í⚪0G⌕ᔲÏᦋ“ᢣᔣḄᢣ┐”ḄᑁÑ0G⌕ᔲ)*Òᢣ┐0᝞1ᢣ┐ÓᨵÀᓄ஺µ2ᵨfreeᡈdeleteÅÆBᑁS²1¹º"ᢣ┐]ÔMNULLoG⌕ᔲ"malloc/freeonew/delete~ᵨ?G⌕mallocuᔲzqÖF0᝞,⁚ᦪᔲzq0HgØᣚᔲzq0G⌕ᙠÚÛ9ÅƼ᝱PQᦪ»Ü1new/deleteḄuᔲzqÖF0....C++YᦪḄ[\ᱯឋ⌕ឋ⚗Ý\ᦪᔲᨵÞឋ0G⌕ᔲ~Bᡂᕒ\ᦪḄÝஹ⌚à9◚â0ã.ḄÝᔲ.ᔠᑴ@Ḅä$å0ᔲᵨᑁὶ\ᦪ0᝞\ᦪᑁḄ3ṹéêë1\ᦪᑁ)*ìí஺

90G⌕ᔲᵨᑁὶ\ᦪ23B43ṹ0...&Ḅ᪀⌼Yᦪஹ᪆᪀YᦪabcYᦪ⌕ឋ⚗G⌕ᔲîïä$åVðC++äñᘤó¼MHôRõOöḕḄ\ᦪ÷µ1öḕḄÖ^ᦪ᪀⌼\ᦪúµ2öḕḄûü᪀⌼\ᦪúµ3öḕḄ᪆᪀\ᦪúµ4öḕḄ¾t\ᦪ஺G⌕᪀⌼\ᦪ&ᔲ⍡ÉB7!ᓄÿG⌕ᔲᙢᵨ᪀⌼ᦪḄᓄ⊤G⌕᪆᪀ᦪᔲ⍡◀ᔲ┯ᑏஹ┯ᵨ᪀⌼ᦪ!"#ᦪG⌕"#ᦪ$%ᑖ'()*+,1-.᩵0"#1,2234ᨵᑁ7891,3ᑖ:;Ḅᑁ789<=>ᑴᑁ@1,4AB*this஺ᔲ⍡D⌕)*G⌕ᔲᙢFᑏGHIḄ᪀⌼ᦪஹ᪆᪀ᦪஹ"#ᦪJKL⚗+1GHINOPQRSIḄ᪀⌼ᦪஹ᪆᪀ᦪஹ"#ᦪ஺2GHIḄ᪀⌼ᦪTᙠᐸᓄ⊤WXᵨSIḄ᪀⌼ᦪ஺3SIYGHIḄ᪆᪀ᦪTZ[\,ᓽ^virtualᐵ`a-஺4ᙠFᑏGHIḄ"#ᦪb

91(2)7ᙠNᦪfIḄ"#ᔩ(3)7ᙠNᦪfIḄᔩG⌕#⚪+(1)Ḅᓄᡈḕ#ᨵ┯ᔩ(2)¢Hx£ᡈ¤£ᔩ(3)Ḅ¥¦§ᔩG⌕vwᑨ©⚪+(1)ᵫ«¥¦4¬®¯ᦔᔩ(2)⊤±²Ḅ³ᐜµᨵᔩ(3)vwᑨ©m¶·᎔ᔩG⌕¹º⚪+(1)¹º»¼ᩩ¾Nᔩ(2)¯¿»¼(À¹º)ᔩ(3)┯ᙢÁᦋ¹ºᔩ(4)7ᙠÄÅÆᔩG⌕┯ᜐᳮ⚪+(1)cdÉÊ┯ᜐᳮᔩ(2)┯ᜐᳮËÌᙽ$ÎÏᨵÐÑÒÓÊ(3)┯ᜐᳮËÌᙽÔÕÖᨵ×Øᔩ᝞ÚÛḄ┯YÜ▭┯N$®<ᜐᳮÞ²Nßß஺(4)┯ᜐᳮËÌᙽ“àáâ”ᔩ᝞ᙠÒÒXᵨãäå¾æç┯஺G⌕ᦻ¾I/O⚪+(1)eN7ᙠḄᡈὅ┯Ḅᦻ¾ÉÊíᔩ(2)ᦻ¾îNḄÞ²ᡭðᔩ(3)ᦻ¾mñᑨ©Nᔩ(4)Ïᨵᙢᐵòᦻ¾ᔩ

92▬ôB+C++/Cõ⚪Ôõ⚪öᵨ«ὃlC++/CËÌᕒḄSÔFËᢈP஺ᑁ@▲«C++/Cᵨú¿

93WஹX)⚪25ᑖYIஹᜮᦻ\Ḅifndef/define/endif]^_ᵨ?2ஹ#include#include"filename.h”ᨵ^_cde3ஹconstᨵ^_ᵨ⌶eg&hijklmY4ஹᙠC++S\oᵨpCqᘤqsḄtᦪL^_⌕wextern“C”xke5ஹ&XyQlzfor{|Ḅ}~///z//Izfor(i=0;i

94ஹᨵᐵᑁḄὃ⚪20ᑖYvoidGetMemory(char*p)char*GetMemory(void)((p=(char*)malloc(100);charp[]="helloworld”;)returnp;voidTest(void)}(voidTest(void)char*str=NULL;(GetMemory(str);char*str=NULL;strcpy(str,"helloworld");str=GetMemory();printf(str);printf(str);))&²³´Testtᦪµᨵ^_᪵Ḅ·¸e&²³´Testtᦪµᨵ^_᪵Ḅ·¸e)A)AVoidGetMemory2(char**p,intnum)voidTest(void)((*p=(char*)malloc(num);char*str=(char*)malloc(100);)strcpy(str,"hello");voidTest(void)free(str);(if(str!=NULL)char*str=NULL;(GetMemory(&str,100);strcpy(str,"world");strcpy(str,஻hello஻);printf(str);printf(str);)})&²³´Testtᦪµᨵ^_᪵Ḅ·¸e&²³´Testtᦪµᨵ^_᪵Ḅ·¸e)A)A

95¾ஹᑏstrcpytᦪ(10ᑖ)¿ÀstrcpytᦪḄÁÂEchar*strcpy(char*strDest,constchar*strSrc);ᐸ\strDestEÄḄÅÆÇstrSrcEÈÅÆÇ஺(1)oᵨC++/CḄÅÆÇÉtᦪ&ᑏtᦪstrcpy(2)strcpyÊstrSrcḄᑁËÌᑴᑮstrDest,L^_Ï⌕char*NÂḄÐÑ9eÒஹᑏNStringḄ᪀⌼tᦪஹ᪆᪀tᦪÖ9tᦪ(25ᑖ)¿ÀNStringḄÁÂLAclassString(public:String(constchar*str=NULL);//×Ø᪀⌼tᦪString(constStringftother);//ÙÚ᪀⌼tᦪஹString(void);//᪆᪀tᦪString&operate=(constString&other);//Ö9tᦪprivate:char*m_data;//ᵨÛÜÅÆÇ)Ý&ᑏStringḄÞy4ztᦪ஺

96▬àCAC++/C⚪Ḅ)ᫀ6âᑖ᪗ä/ஹ&1ᑏBOOL,float,ᢣ┐56“89”;<Ḅif=஺(10ᑖ)&ᑏBOOLflag6"89”;<Ḅif=஺(3ᑖ)᪗ᫀ᝞Qᑏᙳèéêëìᑖ஺if(flag)if(flag==TRUE)if(!flag)if(flag==1)if(flag==FALSE)if(flag==0)&ᑏfloatx6“89”;<Ḅif=»(4ᑖ)᪗ᫀ~constfloatEPSINON=0.00001;᝞QE┯Ḅᑏᑖ஺if((x>=-EPSINON)&&(x<=EPSINON)if(x==0.0)Dôõ5ᵨ“=="ᡈ"ö=”6ᦪÅif(x!=0.0);<÷øùúᓄᡂ“>="ᡈ“<=”MNýþ஺ᑏchar*p“”!Ḅif"#஺(3ᑖ)᪗ᫀ᝞&ᑏᙳ()*+ᑖ஺if(p==NULL)if(p==0)if(p!=NULL)if(p!=0)if(p)if(!)ஹnWindowsNTḄ32C++WhRsizeofḄ((10ᑖ)charstr[]="Hello”;voidFunc(charstr[100])char*p=str;(intn=10;<=<=sizeof(str)=4(2ᑖ)sizeof(str)=6(2ᑖ)}sizeof(p)=4(2ᑖ)void*p=malloc(100);<=sizeof(n)=4(2ᑖ)sizeof(p)=4(2ᑖ)

97ஹde⚪25ᑖIஹᜮᦻCDḄifndef/define/endifEFGᵨIJ5ᑖKe■ijᜮᦻF7Glmᵨ஺2ஹ#includeL#include"filename.h”ᨵFGNOIJ5ᑖKeop#include,rsᘤu᪗wxyz{|}~filename.hop#include"filename.h”,rsᘤuᵨᡝḄyz{|}~filename.h3ஹconstᨵFGᵨ⌶IJQRSTUVKJ5ᑖKe1constUV2const⛲YᦪḄᦪஹc.YᦪḄ஺7const⛲Ḅᑮᑴ.⚜■᜜Ḅ9.[IJḄᏉឋ஺4ஹᙠC++XYDZᵨ[C\]ᘤ\]_Ḅ`ᦪbFG⌕dextern“C”IJ5ᑖKeC++S¡ᢝYᦪG£.CS%¡ᢝYᦪG£஺Yᦪ7C++rs¤ᙠx¦ḄL§PCSḄ%¨஺Ꮇª«¬YᦪḄ®¯voidfoointx,inty;jYᦪ7Crsᘤrs¤ᙠx¦ḄL§¯°f஺஺.±C++rsᘤᑣ6²³´_foo_int_intµ&ḄL§஺C++¶-C·¸¹ᣚᢣ»¼extern“C”ᩭ¾¿L§ᓛÁÂ⚪஺5ஹÃdÄÅƬforÇÈḄÉÊË5ᑖfor(i=0;i

98lஹᨵᐵᑁoḄpὃ⚪(st⚪5ᑖᐳ20ᑖ)voidGetMemory(char*p)char*GetMemory(void)j[ip=(char*)malloc(100);charp[]="helloworld”;)returnp;voidTest(void)}(voidTest(void)char*str=NULL;{GetMemory(str);char*str=NULL;strcpy(str,"helloworld");str=GetMemory();printf(str);printf(str);))Test`ᦪᨵFG᪵ḄITest`ᦪᨵFG᪵ḄIXY஺ṹ஺bGetMemory⌴᝱ᑁobGetMemoryḄᢣᔣ“᪘ᑁo”Test`ᦪDḄstr•—NULL஺Ḅᢣ┐¤ᢣ┐ḄᙢᙬNULL,§ᐸ©strcpy(str,"helloworld");XYªḄᑁ«¬[®◀°ᑁ«±஺஺voidGetMemory2(char**p,intnum)voidTest(void)((*p=(char*)malloc(num);char*str=(char*)malloc(100);)strcpy(str,"hello");voidTest(void)free(str);(if(str!=NULL)char*str=NULL;(GetMemory(&str,100);strcpy(str,"world");strcpy(str,஻hello஻)´printf(str);printf(str);)))Test`ᦪᨵFG᪵ḄITest`ᦪᨵFG᪵ḄIµᦋ᝱ᑁoNḄᑁ«_·¸⚜(1)º»helloᧇ¿Àᓻ◅஺(2)ᑁo¼½bfree(str);Ã_strᡂbÅᢣ┐if(str!=NULL)"#ÆÇᵨ஺

99Èஹ\ᑏstrcpy`ᦪ(10ᑖ)¬±strcpy`ᦪḄ©Échar*strcpy(char*strDest,constchar*strSrc);ᐸDstrDestÊḄËÌÍstrSrcÎËÌÍ஺(1)ZᵨC++/CḄËÌÍÑ`ᦪ\ᑏ`ᦪstrcpychar*strcpy(char*strDest,constchar*strSrc);assert((strDest!=NULL)&&(strSrc!=NULL));//2ᑖchar*address=strDest;//2ᑖwhile((*strDest++=*strSrc++)!=)//2ᑖNULL;returnaddress;//2ᑖ)(2)strcpyÒstrSrcḄᑁ«ÓᑴᑮstrDest,bFGÖ⌕char*×ÉḄIbØÙªÚÛ⊤ÝÛ஺//2ᑖÞ᝞intlength=strlen(strcpy(strDest,uhelloworld"));ßஹ\ᑏ×StringḄ᪀⌼`ᦪஹ᪆᪀`ᦪLã`ᦪ(25ᑖ)¬±×StringḄ©ÉbclassString(public:String(constchar*str=NULL);//æç᪀⌼`ᦪString(constString&other);//èé᪀⌼`ᦪString(void);//᪆᪀`ᦪString&operate=(constString&other);//ã`ᦪprivate:char*m_data;//ᵨëìoËÌÍ)´\ᑏStringḄíî4ð`ᦪ஺᪗òᫀ//StringḄ᪆᪀`ᦪString::^String(void)஻3ᑖdelete[]m_data;//ᵫëm_dataᑁõᦪö×É÷¸ᑏᡂdeletem_data;

100//StringḄæç᪀⌼`ᦪString::String(constchar*str)஻6ᑖ(if(str==NULL)(m_data=newchar[l];//ùdNULLᑨûᑣýþ*m_data='\0';)else(intlength=strlen(str);m_data=newchar[length+1];//NULLᑨ#ᑣ%&strcpy(m__data,str);})//+,᪀⌼/ᦪString::String(constStringfeother)஻3ᑖ(intlength=strlen(other.m_data);m_data=newchar[length+1];//NULLᑨ#ᑣ%&strcpy(m_data,other.m_data);)//9:/ᦪString&String::operate=(constString&other)//13ᑖ(//(1)<=>9:஻4ᑖif(this==&other)return*this;//(2)CDEᨵḄᑁIJK஻3ᑖdelete[]m_data;//(3)ᑖLMḄᑁIJKNOPᑴᑁR஻3ᑖintlength=strlen(other.m_data);m_data=newchar[length+1];//NULLᑨ#ᑣ%&strcpy(m_data,other.m_data);//(4)STUVWḄXᵨ//3ᑖreturn*this;)

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。
关闭