林锐博士-C++编程规范

林锐博士-C++编程规范

ID:83391584

大小:12.50 MB

页数:99页

时间: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++编程规范》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1ᦻ᪀..................................................................91.1᱐ᩗ᱐Ḅ...........................................................91.2ᜮᦻḄ᪀..............................................................101.3ᦻḄ᪀............................................................111.4ᜮᦻḄᵨ..............................................................111.5᪀...................................................................122Ḅ᱐...............................................................132.1.......................................................................132.2ṹ.....................................................................142.3ṹᑁḄ............................................................152.5ᑖ..................................................................172.6⛲Ḅ!..............................................................172.8"Ḅ᱐#..................................................................193!J...................................................................................................................................203.1ᐳឋ&ᑣ..................................................................203.2(ᓫḄWINDOWS*ᵨ+,-.&ᑣ........................................213.3(ᓫḄUNIX*ᵨ+,-.&ᑣ.............................................234⊤........................................................244.1/0Ḅ1ᐜ3............................................................24>2ττ54.3IF45....................................................................254.46745Ḅᦔ᳛............................................................274.5FOR45Ḅ67:ᑴ<=...................................................284.6SWITCH...............................................................................................................................284.7GOTO45.................................................................29>5?@=315.1ABC◤⌕@=............................................................315.2CONSTF#DEFINEḄGH...................................................315.3@=&ᑣ..............................................................315.4"IḄ@=................................................................326vf'”34

16.1JᦪḄ&ᑣ................................................................346.3LᦪᑁMNOḄ&ᑣ.......................................................376.4ᐸQRS..................................................................386.5TᵨUV..................................................................396.6WᵨFᢣ┐ḄGH.........................................................407ᑁᳮ.................................................................427.1ᑁZᑖ[\#..............................................................427.3ᢣ┐Fᦪ]Ḅ^G.........................................................437.4ᢣ_᝞ab⌴ᑁZḄd♦♦♦♦.♦.♦.♦.....♦.♦.♦.♦.♦.♦.♦.♦.♦.♦.♦.♦.♦♦457.5FREEDELETEeᢣ┐fCᖾd............................................487.6h᝱ᑁZjk_hlmᔩd................................................487.7op“rᢣ┐”............................................................497.8ᨵuMALLOC/FREEABCv⌕NEW/DELETE?....................................................................507.9ᑁZὑxfCyd..........................................................517.10MALLOC/FREEḄTᵨ⌕z.................................................527♦11/D/|537.12}~j.............................................................548C++ᦪḄᱯឋ......................................................558.1LᦪḄᭆ............................................................558.2rmj588.3JᦪḄḕ..............................................................618.4/0................................................................628.5Lᦪᑁὶ..................................................................638.6}~j.............................................................669#Ḅ᪀⌼ᦪஹ᪆᪀ᦪ'()ᦪ......................................679.1᪀⌼LᦪF᪆᪀LᦪḄ.................................................67^[-1**********•**************************************************************************************(9.3᪀⌼᪆᪀Ḅ,..........................................................709.4"STRINGḄ᪀⌼LᦪF᪆᪀Lᦪ....................................709.5⌕᪀⌼LᦪFLᦪ.........................................719.6"STRINGḄ᪀⌼LᦪFLᦪ...............................719.7ᏕḄyᜐᳮ᪀⌼LᦪFLᦪ...................................739.8᝞aᙠ"INO"Ḅ¡Lᦪ.........................................739.9}~j.............................................................7510#Ḅ*+',ᔠ.........................................................76

210.1¢£......................................................................761]_τ*••••*•••*••***•**********••***•********************************************************************************************78>11¤ᐸQ¥+¦§...........................................................8011.1TᵨCONST¨©LᦪḄᏉ«ឋ...........................................8011.2¨©+,Ḅᦔ᳛.........................................................8211.3}~ᨵ¬ḄRS.........................................................83Jὃᦻ®.........................................................................85▬A.C++/Cṹ°±⊤......................................................86▬B.C++/C³⚪.............................................................91▬C.C++/C³⚪ḄµᫀF·ᑖ᪗¹...........................................95

31/A”ᑠs»¼=½kᜧ¿ᦪ+,ᕒᢞᙠᘂÃĽmᙠÃḄÅÆÇ◀uÉᐰ᜜ÌÍḄ¥+©Î᜜ÏÐÑÒÏÓᨬᐜḄÕÖ×½ØÙ“ÚÇᡃÜÝÞ⌼ḄC++/C+,fCjᨵßC¿Ḅàád”âãäÏὅæäGÓçèéஹ¿èØÙÄë஺íî}ïðñòóÌ▅Ñõö⚓¦ÒÏÓ×jø¬ùúÏõ½Ý☢NTðÑὅḄRS஺}ஹ¥+ὁÎF©ÎḄýþ_ÿᩭᡂ᠋Ḅᕒᙠ᰿᧕ᡂ!"ᱯ$ᓾ&'(ᡃ*+Ḅ,-஺᝞0ᙠInternet123Ḅ“56”Ḅᕒ89:;᪵Ḅ=(1)56Ḅᕒ>ᨵ@A⊤CᨵDE⚞GḄHIJKᨵ@A⊤56ḄᕒLM⚞GNOPQ஺(2)56ḄᕒRᑏTᵨ9VWᵨᡝYZ([\]^Ḅ_'஺(3)56Ḅᕒ`aRᑏbṹḄde᝞fdeghᑏiᳮᡠZᯠmghn஺(4)56ḄᕒRo2pqrsᦻuKLv;w஺(5)56ḄᕒRxyὃ{|}{sQ~KLx஺(6)56ḄᕒRᑏᦻ᫏mR◤⌕ᦻ᫏CᨵxRḄKᵨᦻ᫏஺(7)56Ḅᕒ([ᵨᡝVᵨᡝ◤⌕஺(8)56ḄᕒRḄᳮ◀([:ᜮᜮ஺(9)56ḄᕒḄRLᙠ6:Ḽᘤ@¢v£30~¤Ḅ¥¦ᦋ┯஺(10)56ḄᕒRLᙠ1ᓤ9:00ᑮ«ᓤ5:00¬®᝞f¯xᑮᙠ1ᓤ9:00®;⊤V°᧤²³vᑮ´ᙠ஺ᐹᜓ1·ᱯ¸¹$¹º»¼½¾¿Àὁ஺ᡠÂ᜻ÄᕒḄg$ÅÆÇᯠÈÉZ®ÊÆᩭËÌ஺ÍᙠÎÏ~9ÐÑÒÓᩭÓÔஹRÖ×ØÙÆÚÛḄ¾{ᨬÝÞ஺ᡃßàm;᪵á᜽ãØäå([ᡂÑ᪵Ḅ“56”Ḅᕒæf>ᨵ»ᑮE«ç஺ᡃ°nᜧéᑮêëìᓝîᩭ³ïðEéñòᑏᦪᓝôC++/Cbṹ஺ᨵ;᪵Ḅõös÷öᡃYøù»1:òὁ{ᔳûᡃḄüýþÿẆᐵ(ᡂᵯCAD3D⚞)ᦪ,ᢈᩖ⚟஺"#$%⚣⚣'ᝄᨵ*+$%',✌./0ᜧ2ᵯᾯᜧ4$

4%67*8ᝄ஺ᙠ1995:;<Ḅ*ᝅ$%?ᑮ2000:AᨵBC஺DᑡF"#“HI”KLMNᡃP,QRSTUᔳWKX"Y+BZ[\8]^_஺`abcᡃdᵨ*:fc;?ᑏᡂᦻCDᙠFGH▅JKLMNOPQᕒḄᐳT஺ᡃUVᨵXYZ[ᜧ\IT]^᝞`aஹGcdeஹfᐶhijḄklmnopq஺ᜧras/tuvw[᳛yMNz⌕|}Ḅ᪶=⚪஺/tuy⌕Ḅ⁚MNy☠ᩭḄ஺ᡃm=fḄὁ0mY/0mᔲᑏ-/tuḄᩭ2ᡃḄᔊv▅ᔊᩭZᑁᜧḄᦟ¡᪷£ᨵ¤¥/tuḄ¦§ᦟ¨mYwm3©Lª«ᐵ=MNḄtu஺®Ḅᕒ¯°ᙠ±tuḄᚮf³´ᔛ¶ᜮ¸<¹ᨵ:º=2>?¯%᩽᠒ᡃy:½஺ᙠZᑁIT]^¾ᨵ¿ஹắ¿ஹÁ¿ᦻÂḄMNOPQᕒÃÃḆyÅmᙠÆÇᜧᦟ“ᐜᜩÊ”Ë:ᑮ]^ÍᯠtḄÏÐ஺ÑᨵÒLMNOPQᕒÓÔÕឋஹᏉØឋஹÙ☠ឋஹᦔ᳛ஹ᧕ᵨឋஹÙÝឋÞÙᳮ|ឋàஹÙ᡽âឋஹÙãᵨឋஹäåឋஹÙæçឋhtuèឋ᝞ᢣêëìᙠífîᵨª᝞஺“/tu”Ùyïð=ñḄ

5ᡃmᨵᐙᑖḄᳮõᶧ⇋ø(1)ὁ0Ù?¯°ᵨ◚ú┯üḄýþ(ᡂᯠ)Ḅ(2)ᙠ⚞ᑏ"᩽ᨵ%&Ḅ'ṹ)*+,-ᐰ/012345Ḅ66☢☢஺9:;<᝞>஺ᡃᑮABCDEFGᩭ▮J☢KᡈMKNOPQ“S”“ὁ”VᕒḄᢈ,45ᔠZ᳛ᜧ]10%஺^_ᨵ`,aᑏ"bᐰcᔠ45⌕eḄiffg^hVᕒiᢣ┐ஹᑁnoᳮqrs.......⚞uvᦢxḄ஺ᡃyNzK{|ᨵ}~S14Qắᙠiv“C++/Cᢈ,”᥎ὃK஺ᡃᜧK⚪ᡠᨵḄ`஺ᨵ`Zᨵrᦪ`ᑖ஺¡i¢£Ḅ¤¥v¦yNK{§᪵©ªᙢ஺Ḅᡃ“¬®”ᡈὅ⌕eN°^h23`ᕒi±Ḅ⌕ea஺⌕q⍝³´ஹABCDஹµᐶ·¢£ḄᕒE¸4ᙠ¹ᑁITº»µ¼½ᑡḄ᎚ÀvḄ45᝞>ÁḄÂᡃvÃÄᦢÅƵǢ£È"45Ḅ23ᕖÊVËÌÍÎÄÏᐶÐÑ23Ò»ÓÔÕ஺ᡃᡭ×ØÙὁÚÛÜÝÞß஺ØÙ1,àÅáØᙢᑏ"45VḄVᕒâ´ὁ஺ØÙ2,àÅáØᙢᑏ"ãஹ45VḄVᕒâ´஺᪷åAæØÙçAᑮèéê|ᡃë¦×Aὁ஺ᙠᑏ>ìᡃ▅îï_Vðñ6☢Ḅòᦻ℉Fõöõ÷ø஺ù´±Êúûᢈ,*,ᐰ☢ü1⚔h×þÿὁ஺ᡃ᪵ᙠᑁḄᕒ!"#ᑮ%(1)&┯(ᦋ*(2)+,-ᦑ/&0;(3)2ᢝ45ᜩᜩᔣ8஺

6ஹ✌ᐜ<#▬>BḄC++/CC⚪EF⌕HIᫀKὃMNOḄPQRST᝞V஺ᯠXY᯿Iᫀ[\ᡭᑖ஺E1K᝞`abcdeᓝᑖᑏ@A₝᝞2ᦋDEᨵF៎Ḅ9᎛஺HIJ᪵⍝ᳮ஺NOPQNᓝ•PIS⚪UVᢈXYZ()[4'9⌕\᩽^ὃ஺ᱯaINOP“ᑁdeᳮ”"g2⊤ijjg2⊤i.kDlmᵨ஺ᨵnoJp4NOPF$%''rᢣ┐”ᑏ%2┯vᡃᑗynz஺I{|ᕜ~ᡃ~|ᜩnBug,2ᑮI“rᢣ┐”⚪3"NOP஺ᐝ4&'[Iᨵ▲Ḅᜧ▅"&'ḄὃᦻIᐺ℉஺᝞+Ḅ¢{ᐵ2⌕.¤¥¦஺᝞+ᡂ¨©ªḄ«¬6ᕒ+▅"gᢥ᯿CMMI²5p´µ¶Ḅ·ᔠ¸¹ºᓣn¼▤஺º¾¿ÀḄᕒ,ÁᔣÃÄÅᵨpÆÇ«¬,Ẇ8ÉÊCMMIᨵᐵËᧇᨬkÎÏÐ஺

7ஹ᱐ᩗ&'ḄᜧÇᑖᑁÓÊᩞÕ-ὅnÖ×Ḅ'ØÙÚÛÜÝ᱐ßà᦮ᳮâᡂ¨º¾¿ÀÃÄÅᵨpÆÇḄ²ᓄᦻ¬J9-¨ÏÐᦟᩞ஺ᵫÕC++/CIèᡠᕜéḄᢈXêᨵëìí஺ḄîÅïᜧᐳñᡃòµ¶HIóôᩭḄ஺-ὅö÷ø&'Ḅᵯúᦻ᫏஺᱐ᩗýþ᝞ÿ1ὅஹᦋḄᑁᦋὅᡠᓫ஺2!ὅ"#$᱐ᡈᜧ(ᓺ*஺3᝞-./0123Ḅᕒ5#ᑮ7829:ᵨ<*=>?஺⚜Aᑮ2002C7ᨴᡃGHIJᑗᔠMNNOḄCMMI3TUVWᫀ஺YZᒹ\ᙠᑁḄ^1000⚓`Hbcde஺fgὅ0h$ᢇjIk஺᪍┦2001C7ᨴ

8n1oᦻqr᪀tuC++/Cvwxyᑖ{|uᦻq஺}uᦻqᵨ~vwḄ(declaration),{ᜮᦻq஺•uᦻqᵨ~vwḄ(implementation),{(definition)ᦻq஺C++/CvwḄᜮᦻq“.h”{CvwḄᦻq“.c”{C++vwḄᦻqxy“.cpp”{(ᨵ•“.cc”ᡈ“.cxx”{)஺1.1᱐ᩗ᱐Ḅ᱐ᩗ᱐Ḅ~ᜮᦻqᦻqḄ9ᜮ(1-1),⌕ᑁᨵ:(1)᱐ᩗ஺(2)ᦻq᪗¡¢᤺⌕஺(3)¤¥᱐¦ὅ/ᦋὅ¨ᡂª«஺(4)᱐ᔊ஺/**Copyright(c)2001,¯°±ᨵ▲23³´µᵨ¶·¸*Allrightsreserved.**ᦻqfi1ename,h*ᦻq᪗¡ᳮᑜ*᤺⌕⌕ᦻḄᑁ**¤¥᱐1.1*ὅᐭ!ὅ(ᡈ$ᦋὅ)'(*¨ᡂª«2001+7ᨴ20.**¹º᱐1.0*»ὅᐭ/!ὅ(ᡈ$ᦋὅ)'(*¨ᡂª«2001+5ᨴ10.*/1T᱐ᩗ᱐Ḅ

91.2ᜮᦻqḄr᪀ᜮᦻqᵫ½¸ᑖᑁ¾ᡂ1ᜮᦻq9ᜮᜐḄ᱐ᩗ᱐1-1஺2⚜ᜐᳮᙽ஺3ÂᦪÄr᪀Å஺ᎷÇᜮᦻq{graphics,h,ᜮᦻqḄr᪀1-2஺•ூ`ᑣ121௃{Ë■ÍᜮᦻqÎÏÐÑᵨµ¤ᵨifndef/define/endifr᪀Ò=⚜ᜐᳮᙽ஺•ூ`ᑣ1-2-2௃ᵨ#includecÓᩭÑᵨ᪗ÕÖḄᜮᦻq×ØᘤHÚ᪗ÕÖÛÜ9ÝÞß஺•ூ`ᑣ1-2-3ᵨttinclude“filename.!!”cÓᩭÑᵨà᪗ÕÖḄᜮᦻq×ØᘤHÚᵨᡝḄ5ÛÜ9ÝÞß஺âூIk1-2-11ᜮᦻqMãä“”çä“”ᙠC++èéMÄḄᡂᕒÂᦪᙠḄêZÎëìíîᡂ{ᑁὶÂᦪ஺ðñᯠóôᩭᑏ¯ḄWöᓾ⌼ᡂËùc}úûᜧ~ᑭ஺IkHᡂᕒÂᦪḄýᑖ9þÿᦪᨵ஺ூ1-2-2᎝ᵨᐰ⌕ᙠᜮᦻexternintvalue!"#$஺//᱐ᩗ(᱐)#$*+,1-1,-ᜐḕᶍ஺#ifndefGRAPHICS1//■3graphics.h4567ᵨttdefineGRAPHICSJI^include//7ᵨ᪗9:Ḅᜮᦻ#include“myheader.h"//7ᵨ<᪗9:ḄᜮᦻvoidFunctionl•••;//ᐰᦪ#$classBox//"=᪀#$?#endif+,1-2C++/CᜮᦻḄ=᪀

101.3@AᦻḄ=᪀@AᦻᨵBCᑖᑁFG1@AᦻHᜮᜐḄ᱐ᩗ(᱐)#$IJ*+,1-1஺I2KLMᜮᦻḄ7ᵨ஺I3NOḄPIᒹRᦪS(TṹV஺ᎷX@AᦻḄYZ[graphics,cpp,@AᦻḄ=᪀J*+,1-3஺//᱐ᩗ(᱐)#$*+,1-1,-ᜐḕᶍ஺^include“graphics.h"//7ᵨᜮᦻ//ᐰᦪḄPvoidFunctionl•,,//"ᡂᕒᦪḄPvoidBox::DrawV+,1-3C++/C@AᦻḄ=᪀1.4ᜮᦻḄ^ᵨ_`ḄaNbc᝞Basic.FortraneᨵᜮᦻḄᭆgC++/CbcḄhiὅkᯠmᵨᵨᜮᦻnoo$ᐸᳮ஺!rKᜮᦻḄ^ᵨᶍ^stG1uvᜮᦻᩭxᵨ:yz஺ᙠ{|ᔠ~TṹIᡈ9Vᔣᵨᡝ⌕ᔣᵨᡝᜮᦻ(ᑴḄ:ᓽ஺ᵨᡝ◤⌕ᢥ᯿ᜮᦻḄ#$ᩭxᵨ:yzᐵPḄ஺aᘤm:ḄTṹ஺I2ᜮᦻz"ᐰ¡஺᝞¢£¤4Pᡈ4ᵨ¥ᐸ¦§¨ᜮᦻḄ#$L©aᘤªmᢣ┯!L®ᓫḄ°ᑣzᜧᜧ³´NOᕒxµஹᦋ┯Ḅ¸¹஺

111.5᪀᝞¢L¤ºḄᜮᦻᦪ»¼½I᝞¾vᓝ¤VuoÀᜮᦻ(@AᦻᑖÁÂÃÄÅḄ»ÆÇÄÈÉ஺,᝞ÀᜮᦻÂÃÄinclude»ÆÀ@AᦻÂÃÄsource»ÆIÇÊË»ÆV஺᝞¢£MᜮᦻÊÌᨵḄÍm4ᵨᡝḄNOÎ7ᵨᑣeᨵ⌕Hᐸ“#$”஺[ÑÒÓ◚Õ!MÌᨵḄᜮᦻÇ(@AᦻÃÖÄÅL¤»Æ஺

12×2ØNOḄ᱐§᱐§kᯠmÙÚNOḄyznmÙÚÛឋ஺NOḄ᱐§ÝÞßᨎஹáâÊNOãäḄ5⌕᪀ᡂåæ஺ÇçNOḄ᱐§¼è[“éê”஺ëḄ“éê”ìíKNOL»Ñᯠîïᐶ©ññ஺òḄNO“éê”᝞≏ôõöìíîï÷ᯠøᕡúÈÉὅûüᨵ஺ýNOᕒþiÿḄ“”⊡ᜧᦟḄᙠᨵ⌕஺2.1Ḽᑖ◞!"Ḅ#ᵨ஺%&(()*+(),)./Ḅ01234ᨎ஺(678ᑁ:;ᯠᡭᓺ?ᨵḄ@6*AὑCDEFG@H%஺ᡠJ(⌕K(%ᵨ஺•ூNᑣ2-1-12ᙠPQRSTUVஹPQXᦪZ[\]UV^⌕3஺_`ab2-1(a)•ூNᑣ2-1-22ᙠCQXᦪ&ᑁcdefᑗhᐵḄjkUl(3ᐸnᙢpq3ᑖ◞஺_`ab2-1(b)////voidFunctionl(•,,)while(condition)((statementls)////if(condition)voidFunction2(••,)((statement2s)}else//(voidFunction3(••,)statement?s()//}statement4s)ab2-1(a)XᦪUlḄab2-l(b)XᦪᑁtḄ

132.2uṹ•ூNᑣ2-2-1௃CuṹxyCz{|᝞xZ[CQ~ᡈxᑏCᩩjk஺᪵Ḅuṹ᧕▅pᑏ஺•ூNᑣ2-2-2௃ifஹforஹwhile,dojkᓰC᡻jk(%ᐸV஺(᡻jkᨵ*,^⌕3஺᪵J■ᑏᜫ஺ab2-2(a)¡Ḅuṹab2-2(b)(Ḅuṹ஺intwidth;//®intwidth,height,depth;//®±®³®intheight;//±®intdepth;//³®x=a+b;X=a+b;y=c+d;z=e+f;y=c+d;z=e+f;if(width

142.3uṹᑁḄ•ூNᑣ2-3-1௃ᐵæçUV⌕ᶇ஺éconstஹvirtualஹinline^caseᐵæçUVê,⌕ᶇCQᔲᑣìí᪆ᐵæç஺éifஹforஹwhileᐵæçUVqᶇ--Qïðñò'('Jôõᐵæç஺•ூNᑣ2-3-2௃XᦪöUV(⌕ᶇðñò'('J÷ᐵæçøù஺•ூNᑣ2-3-31'('ᔣVᔣûᜐ(ᶇ஺•ூNᑣ2-3-41‘’UV⌕ᶇ᝞Function^,y,z)஺᝞Ò's’(@CḄ\]þòᐸV⌕ᶇ᝞for(initialization;condition;update)»•ூNᑣ2-3-52ÿஹஹஹஹ᝞“="ஹ“+=”“II”ஹᐗḄ஺•ூ#$I%2-3-61&ᐗ᝞“&”ஹ(ᙢᙬ*),஺•ூ#ᑣ2-3-72./0,஺1ூ232-3-1௃56⊤89:Ḅfor;<=if;<>?@ABCDE〉ᙢGᣵ&I,᝞for(i=0;i<10;i++)=if((av=b)&&(cv=d))voidFund(intx,inty,intz);//RSḄTvoidFund(intx,inty,intz);//,RḄTif(year>=2000)//RSḄTif(year>=2000)//,RḄTif((a>=b)&&(c<=d))//RSḄTif(a>=b&&c<=d)//,RḄTfor(i=0;i<10;i++)//RSḄTfor(i=0;i<10;i++)//,RḄTfor(i=0;I<10;i++)//UVḄx=aFunction();//,⌕ᑏᡂb->Function();KL2-3MṹOᑁḄ

152.45Z•ூ#ᑣ2-4-1௃[\Ḅᑖ^'{'='}'bᓰ&Ode6f,ᑡfhijᵨlmḄ;TRSḄ5ZKL2-4(b)>T,RḄ5Z஺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)}᝞vwxyᝅḄ{},ᑣ{ᵨ|}5Z᝞~{()}KL2-4(a)=>?@Ḅ5ZKL2-4(b)=>A?Ḅ5Z

162.5:Oᑖ•ூ#ᑣ2-5-1௃MṹOᨬᜧ:ᑴᙠ7080Eᑁ.MṹO,⌕U:ᔲᑣ,Uᩭ,6ᡭᓺ஺•ூ#ᑣ2-5-22:⊤89⌕ᙠᐜᜐᑖᡂOᙠOo✌(Ew)஺ᑖwḄO⌕}O〉Ḅ|}{᣸᱐᦮Z;=verylongervariable12)&&(very_longer_variable3<=very_longer_variablel4)&&(verylongervariables<=verylongervariablel6))(dosomething();virtualCMatrixCMultiplyMatrix(CMatrixleftMatrix,CMatrixrightMatrix);for(verylongerinitialization;very_longer_condition;very_longer_update)(dosomething();JKL2-5:OḄᑖ2.6⛲Ḅ¡⛲*=&¤☠¦ᦪ§0¨©ª¤☠¦«¬ªᨵ¯3Ḅ°⚪஺²³⛲*☠¦ᦪ§0¨L᝞~int*x;´;µ¶·¸ᑏ¹º»ᓽxªint0¨Ḅᢣ┐஺¶¿ᑏ¹ḄÀÁªÂ᧕jBÄÅL᝞~int*X,y;¸ᜐyÂ᧕ÆÄÅ>ᢣ┐«¬஺Çᯠ³x=yᑖOɵDEÊËÄÅÌd,ªÍÍÎÏÐ/᪵Ò஺•ூ#ᑣ2-6-1௃³⛲*=&@☠«¬L᝞~char*name;int*x,y;//¸ᜐy,ÓÆÄÅ>ᢣ┐

172.7ÔÕc;ÖḄÔÕ>"/*_*/ஹC++;ÖØ[\ᙽḄÔÕÙÚᵨ"/*…*/"OÔÕ&ÜÚᵨÔÕÝÙᵨ6~Þ1᱐ßஹ᱐ᩗáâãÞ2äᦪåæçâãÞ3è⌕ḄMṹOᡈêëìK஺ÇᯠÔÕᨵí6ᳮÅMṹÌÔÐ,DUVᙢ{ᵨÔÕ஺ïCKL2-6஺•ூ#ᑣ2-7-12ÔÕª5MṹḄ“ìK”ð,ªᦻ᫏஺[\ØḄÔÕ,DóôõöÔÕ÷V?ÓøÍùúû஺ÔÕḄù᪵⌕ü஺•ூ#ᑣ2-7-2௃᝞vMṹßᩭýªþÿḄᑣ஺ᔲᑣ஺᝞i++;஻i1,Ḅ•ூᑣ2-7-3௃ᑏṹᦋṹ!ᦋ"#Ḅ$%&'ṹḄ(ឋ஺*ᨵᵨḄ⌕ᑤ◀஺•ூᑣ2-7-42#012ஹ᧕5■7ᨵ89ឋ஺┯;Ḅ<=>?@ᨵA஺•ூᑣ2-7-52BCDEᙠGHᵨIᑏᱯKLMᵨIᑏ஺•ூᑣ2-7-62ḄNO#'PQRḄṹ"ST$UᙠṹḄVWᡈYWTUᙠZW஺•ூᑣ2-7-8௃0ṹ[\]ᱯKLᨵ^_ᝅ!#0ᙠabcḄdeᜐgh▅j஺/*if(…)*oᦪqrs(*tᐭvᦪs*twvᦪswhile(...)*xyzs(*/voidFunction(floatx,floaty,floatz)}//endofwhile{}//endofifIk2-6lmḄ

182.8!Ḅ᱐#|T$}ᦪ~oᦪᙠᐸGoᦪ⊤k|Ḅ(ᡈ)஺|ᐵpublicஹprotectedprivate,ᑖKᵨhaᦪ~oᦪLᨵḄஹ%ḄᡈὅLᨵḄ஺᪵T$ᑮ◚¡Ḅ¢Ḅᓽ¤|¥¥¦§⌕¤᜜©ª⍝Ḅᑁ@◚¡ᐸ®ᑗᑁ஺ᡃ±T$²ᵨ|Ḅ³´⌕µ®0ᡂ·┡¹º»¼½¾¿ᡮ஺|Ḅ᱐ÂÃ⌕ᨵÄÅWÂs(1)}private|ÆḄᦪ~ᑏᙠÇ☢@}public|ÆḄoᦪᑏᙠÉ☢᝞k8-3(a)஺ÊᵨÅ᱐ÂḄlmᕒÃÌ|ḄÍΓ$ᦪ~GД^Òᐵ|ḄᑁÓd᪀஺(2)}public|ÆḄoᦪᑏᙠÇ☢@}private|ÆḄᦪ~ᑏᙠÉ☢᝞k8.3(b)ÊᵨÅ᱐ÂḄlmᕒÃÌ|ḄÍΓ$GД^ÒᐵḄL|#Õ¹º᪵ḄÖ×(ᡈ)஺ØC++ᦟÚÛᑮBiarneStroustrupÜÝ℉ßḄàáªâᙢÊᵨ“$ᦪ~GДḄÛᑏWÂäåæᨵç⍝ᳮ஺ᡃéêjὅÊᵨ“$GДḄÛᑏWÂᓽ✌ᐜὃ⇋|#Õ¹º᪵Ḅoᦪ஺LØḄïð“᪵ñ¥¤òóᙠÍÎ|!ôõöᨎ@øWgK▅j஺ùᵨᡝᨬᐵÐḄLÖ×üýþᐜÿᑮᚮᨵᦪᡂᕒ”classAclassA((private:public:inti,j;voidFund(void);floatx,y;voidEunc2(void);public:private:voidFund(void);inti,j;voidFunc2(void);floatx,y;)}8.3(a)ᦪ᱐8.3(b)Ḅ᱐

193ᑣ℉ḄᑣMicrosoft!"Ḅ“ᒼᱛᑭ”'()ᑣḄ*⌕,-.“ᙠ0123ᦪ4ᐭ6789:;<=>Ḅᳮ@”஺᝞ᡠᨵḄDE01ᙳch67(G.ᢣ┐01ᑣJ467P஺᝞KL01ᵫppchNᜮ(ᑣ⊤QR.ᢣᔣDEᢣ┐Ḅᢣ┐஺“ᒼᱛᑭ”'ᨬᜧḄVW.Xᳲ(᝞inti,j,k;floatx,y,z;᎚G[ᵨ“ᒼᱛᑭ”ᑣ(ᑣ]ᑏᡂintil,ij,ik;//67i⊤int`afloatfX,fY,fZ;//67f⊤float`a᝞bXᳲḄ=>cdeᜧfᦪ=>ᕒg'hi஺ὃk(lᨵmᑣndᡠᨵḄ=>ᕒop(=>qrᦟtuvwxᢣyᑣ஺ᑣᕒ[¢Ḅ(ᡃ;]ᙠ⍳¤¥¦ᐳឋᑣḄ6§¨(©᡽ᐙᱯyḄᑣ(᝞3.2⁚஺•ூᑣ3-1-1௃᪗±E]²³´nµ¶(n·ᦻ¹(xº9“@ṹ”஺᪗±Eᨬ[ᵨ¼ᦻᓫ¾ᡈᐸÁᔠ(ÃÄÅÆ2▅¶஺ᑗÉÊᵨË̵Íᩭ஺=>Ḅ¼ᦻᓫ¾vxcÏᩖ(ᵨ¾]ÑÒ஺᝞x⌕ÓCurrentvalueᑏᡂNowValue஺•ூᑣ3-1-2௃᪗±EḄÔÕ]Eᔠ^min-length&&max-information”Öᑣ஺×ᓝÙ6ὁANSICyDxÑÛÜ6LDE(ÝÞḄC++/Cx©ᨵb▲ᑴ஺vᩭà(ÔDáâᙢ⊤äåæ(ᡠ3ᦪஹ01ஹ`Ôäᓝ×LDExèé஺êëD.ᔲíÔîïxðñ᝞01maxvalòmaxValueUntilOverflowᵨ஺ᓫDEḄDó.ᨵᵨḄ(ôðḄ᝞[M,11,3*,ö(2÷(R;øônᵨù3ᦪ[ᑁḄûü01஺•ூᑣ3-1-3௃ᑣý1þᡠ[ᵨḄÿᡈᐹḄᢝ஺᝞WindowsᵨḄ᪗ᵨ“ᜧᑏ”!᣸Ḅ#$%᝞AddChild஺&UnixᵨḄ᪗ᵨ“ᑏ'(ᑜ*”Ḅ#$%᝞add_child஺+,-./

20!ᙠ2ᵨ஺•ூ5ᑣ3-1-4௃89⌕HI;<☠ᜧᑏ>ᑖḄ@AḄ᪗஺᝞Bintx,X;஻DExFXG᧕!Ivoidf00(intx);//KᦪfooFFOOG᧕!IvoidFOO(floatx);•ூ5ᑣ3-1-5௃89⌕M;᪗Nᐰ@PḄQRDESᐰQDE%TU.ὅḄᵨW9P&9XYZ[┯]%^X_`]a஺•ூ5ᑣ3-1-6DEḄbcd_ᵨ“be”ᡈὅ“fGe+be:᝞Bfloatvalue;floatoldValue;floatnewValue;•ூ5ᑣ3-1-7ᐰQKᦪḄbcd_ᵨ“ie”ᡈὅ“ie+be”(ikel)஺/ḄᡂᕒKᦪdp_ᵨ“ie”%qḕᶍᣵḄbeuvwxyz஺᝞BDrawBox();//ᐰQKᦪbox->Draw();///ḄᡂᕒKᦪ•ூ5ᑣ3-1-8ᵨ{|Ḅ}~elbᐹᨵ~ḄDEᡈ@}iḄKᦪ஺᝞BintminValue;intmaxValue;intSetValue(...);intGetValue(...);ூ3-1-1௃TEbc8M;ᦪc%᝞Valuel,Value2%◀Ḅ|◤⌕஺-v■ᕒᏕ%9biᾯ&Y~Ḅbc(ᵨᦪcᨬḕ)஺3.2¡ᓫḄWindowsᵨb5ᑣὅw“ᒼᱛᑭ”b5ᑣ¦ᔠᳮḄ¡ᓄ%(ªḄb5ᑣ¡ᓫ᧕ᵨ%«¬〉ᔠ®Windowsᵨ¯°Ḅ஺

21•ூ5ᑣ3-2-1௃/bSKᦪbᵨᜧᑏc±ᜮḄᓫelᔠ&ᡂ஺᝞BclassNode;///bclassLeafNode;///bvoidDraw(void);//KᦪbvoidSetValue(intvalue);//Kᦪb•ூ5ᑣ3-2-22DES³ᦪᵨᑏc±ᜮḄᓫelᔠ&ᡂ஺᝞BBOOLflag;intdrawMode;•ூ5ᑣ3-2-3௃EᐰᵨᜧᑏḄc±%ᵨ(ᑜ*ᑖᒘᓫe஺᝞BconstintMAX=100;constintMAX_LENGTH=100;•ூ5ᑣI3-2-41☟᝱DE'·¸s_(⊤ºstatic)o᝞BvoidInit(...)(staticints_initValue;//☟᝱DE)•ூ5ᑣ3-2-52᝞»9¼½◤⌕ᐰQDE%ᑣ_ᐰQDE'·¸¾_(⊤ºglobal)஺᝞Bintg_howManyPeople;//ᐰQDEintg_howMuchMoney;//ᐰQDE•ூ5ᑣ3-2-62/ḄᦪÀᡂᕒ'·¸m_(⊤ºmember),-᪵ÂÃᦪÀᡂᕒFᡂᕒKᦪḄ³ᦪPb஺᝞BvoidObject::SetValue(intwidth,intheight){mwidth=width;m_height=height;}

22•ூ5ᑣ3-2-7■Ư°Ç8ḄÈ᪗Sᐸʯ°Ç8ḄËÌ%ÂÃᔜÎ᪗'Ï}᧜¯°ឋÒḄ·¸஺᝞ÓÔÕf᪗ÖOpenGLḄᡠᨵÇKᦪᙳÃglᜮ%ᡠᨵEÙᡈÚÛ~ÜᙳÃGLᜮ஺3.3¡ᓫḄUnixᵨb5ᑣ

23Ý4Þ⊤ß$SàyZáâὅÂÏᝰᶧBåifஹforஹwhileஹgoto,switch-᪵¡ᓫḄçèé⌕êë%v9v⚪ᜧ¦íᡃïḄðñòᕒᵨ◚ô┯]Ḅ#$ᑏ⊤ß$SàyZá%ᡃõöé÷ø/AḄ┯]஺⊤ß$SZáùú®C++/CḄûZü᪀Z[஺Êþÿᓫ.ᵨ◚஺ᵨ⊤Ḅᑣ!"#஺4.1$&'Ḅ(ᐜ*C++/C+Ḅ$&'ᨵᦪᓝ/$&'Ḅ(ᐜ*!0ᔠ2᝞⊤4-1ᡠ5஺67ᐗ$&'+-*Ḅ(ᐜ*<=>?Ḅ@ᐗ$&'஺(ᐜ*$&'0ᔠ2()[]>.ABCD!~++--(FG)sizeofADCBA+-*&//%ABCD+-ABCD«»ABCDᑮ<<=>>=ABCD|===ABCDJ&ABCDAABCD᣸1ABCD&&ABCDᑡIIADCB?NADCB=+="=*=/=%=&=A=ABCD1=«=»=⊤4-1$&'Ḅ(ᐜ*!0ᔠ2•ூᑣ4-1-1௃᝞NOṹQRḄSTUVWXYᵨOPQ⊤ḄRSTUVWᵨXYḄ(ᐜ*஺ᵫ=[⊤4-1\]^_`Ḅa■cdefghi

24if((aIb)&&(a&c))4.2oᔠ⊤᝞a=b=c=Op᪵Ḅ⊤raoᔠ⊤஺ᐕtoᔠ⊤uᙠḄᳮᵫ^N(1)xᑏz{(2)j|i<}~ᦔ᳛஺⌕■cᵨoᔠ⊤஺•ூᑣ4-2-1௃⌕}ᑏoᩖḄoᔠ⊤஺n᝞Ni=a>=b&&c

25if(!flag)//⊤5flagaᎷᐸÑḄᵨÚÅÛ=ÜÝÞn᝞Nif(flag==TRUE)if(flag==1)if(flag==FALSE)if(flag==0)4.3.2᦮G·¸!°•ூëIì4-3-2?m[᦮G·¸ᵨ“=="ᡈ“î=”¹º!0஺ᎷÎ᦮G·¸ḄÏÐavalue,Ñ!°Ḅ᪗Íif᝞ÒNif(value==0)if(value!=0)jóôµ¶·¸ḄÝÞᑏᡂif(value)//õö¢¤value^µ¶·¸if(!value)4.3.3÷ø·¸!°•ூëII4-3-3j[÷ø·¸ᵨ“=="ᡈ"î=”!ÂÃᦪÐ஺ᓟú⌕ᶇ7ü´^floatÿdoubleḄᨵ▲ᑴ஺ᡠ⌕ᵨ“=="ᡈ"$=”&ᦪ()*+,-./ᓄᡂ“>="ᡈ“<=”45஺Ꮇ-Ḅ7(8X,+;if(x==0.0)஻◚E┯GḄ)*/ᓄ8if((x>=-EPSIN0N)&&(x<=EPSIN0N))ᐸPEPSIN0NᐕRḄGS(ᓽ)஺4.3.4ᢣ┐&WX)*•ூ[ᑣ4-3-41+;ᢣ┐ᵨ“=="ᡈ.="&NULL)*஺ᢣ┐ḄWX“_”(`8NULL),abNULLḄX&0cdefὅhijd஺Ꮇ-ᢣ┐Ḅ7(8Pk&WX)*Ḅ᪗mifno᝞qrif(p==NULL)//p&NULLu5)*vwpᢣ┐if(p!=NULL)j⌕ᑏᡂif(p==0)//z᧕|}G~p᦮if(p!=0)ᡈὅif(P)//z᧕|}G~Pif(!p)4.3.5ifnoḄ⊡ᐙ

26ᨵ᎛ᡃᑮif(NULL==p)᪵Ḅ5஺jᑏ┯ᕒ8■if(p==NULL)Gᑏᡂif(p=NULL),ᨵhpNULL᎔஺¡ᘤ£8if(p=NULL)ᔠ.Ḅeᢣ¥if(NULL=p)┯GḄ¦8NULLj§¨X஺Pᨵ⍗ᑮif/else/returnḄ®ᔠ+,᝞qj¯°Ḅif(condition)returnx;returny;ᦋᑏ8if(condition)(returnx;}else(returny;)ᡈὅᦋᑏᡂ¶·¸¹Ḅreturn(condition?x:y);4.4¼½noḄᦔ᳛C++/C¼½noPfornoÂᵨ⚣᳛ᨬÅwhilenoᐸÈdonoÉÊᵨ஺Ë⁚ÍÎϼ½ÐḄᦔ᳛஺Ñż½Ðᦔ᳛ḄÒËÓ.ÔÕ¼½ÐḄÖᩖឋ஺•ூÙÚ4-4-1௃ᙠÝͼ½P᝞Þᨵ+;ᨬßḄ¼½àᙠᨬᑁâᨬãḄ¼½àᙠᨬ᜜âåÊCPUæᑗ¼½âḄÈᦪ஺è᝞éè4-4(b)Ḅᦔ᳛)éè4-4(a)ḄÅ஺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)Õᦔ᳛rß¼½ᙠᨬ᜜âéè4-4(b)Åᦔ᳛rß¼½ᙠᨬᑁâூÙÚ4-4-2௃᝞Þ¼½Ðᑁìᙠíîᑨðñò¼½ÈᦪÉᜧôíîᑨðõᑮ

27¼½ÐḄ᜜☢஺éè4-4(c)Ḅ)éè4-4(d)Ý᡻øN-1Èíîᑨð஺ñòᵫûüὅὁ⌕þøíîᑨðᡭ“”ᘤᓄᜐᳮᦔ᳛஺᝞N"#ᜧᨬ&'ᵨ)*4-4(d)Ḅᑏ23456ᦔ᳛஺᝞N"#78ὅᦔ᳛:;<=>'ᵨ)*4-4(c)Ḅᑏ2@A&BCDEFGHI஺for(i=0;i

28switch¢ᑖ¤⌱¦cd§ifcd¨ᨵ8©ᑖ¤3ª⌱¦஺«ᯠ34ᵨᝅḄifcdᩭ°±¢ᑖ¤⌱¦b²᪵ḄDEᑍµ¶·஺¸switchcd¹ᙠḄᳮᵫ஺switchcdḄ»¼½¾¿switch(variable)(casevaluel:break;casevalue2:…break;default:break;)•ூkᑣ4-6-11Æ©casecdḄÇÈ⌕ÉGbreak,ᔲᑣËÌÍ¢©ᑖ¤ÎÏ(◀"ᨵÑ¢©ᑖ¤ÎÏ)஺•ூkÒU462௃⌕ÉÓᨬÔ²©defaultᑖ¤஺ᓽDEÖḄ◤⌕defaultᜐᳮ,ØÙÚÛᶇcddefault:break;¸᪵Ý<"¢Þßà§C■s;áâ4CãÉdefaultᜐᳮ஺4.7gotocdäå5᎝Ç᪀ᓄèé4ᩭgot஺êᡂᨵìwḄcd஺✌ᐜᵫgotocd34ᮣðñò᝞G▲ᑴôḄõöẚøÇ᪀ᓄèéù½஺ᐸgot஺cdû#üᩭ┯âᡈ◚஺Ḅ᪀⌼ஹḄᓄஹ⌕Ḅ᝞gotostate;Stringsi,s2;///gotointsum=0;///gotostate:᝞567ᘤ9:;<=┯?@ᵨBCgotoDᶇF◚஺HIJKLM◀C++/CḄgotoQRS஺TUVWXᙢZ┯?X[\ᕒ^_⌼ᡂḄ9Xgot஺Ḅ┯஺gotoabᨵBᜐefghIijklmᙢBFnᑮ᜜☢ᵨ9ḼᑏHICḄbreakv᝞gotoerror;

29error:wxyḼzᩭ9|hx}B~B~Fhzᙷ஺ᡠQᡃbᵨஹᵨgoto9XἭᵨ஺

305XB᪗Ḅᙠឤ9஺Cᵨ#defineᩭ¡¢£¤¥஺C++◀#define᜜¦Qᵨconstᩭ¡¢£const¥஺5.1£¨©◤⌕᝞59«ᵨ¬ᙠ[\l®ᑏᦪ°ᡈ°²³´ᨵ¨©µ¶·¡1¥[\Ḅ¹ឋ¡ᳮ¼ឋ¥½஺[\ᕒ^_´¾¿Àᦪ°ᡈ°²X¨©ÁÂᵨᡝᑣÅÆ9ÇhÈᜐᩭஹ⊤ʨ©஺¡2¥ᙠ[\ḄHIᙢËÌᐭÎ᪵Ḅᦪ°ᡈ°²ÐÑ9:ÒÓᑏ┯?஺¡3¥᝞5⌕Õᦋᦪ°ᡈ°²ᑣ´ᙠHIᙢËᦋ×ص¶ÙÚ᧕┯஺•ூÞᑣ5-1-12ß«ᵨà¬áḄᩭ⊤ÊÀ³ᙠ[\lICâḄᦪ°ᡈ°²஺᝞tfdefineMAX100/*CḄ¤*/constintMAX=100;//C++ḄconstconstfloatPI=3.14159;//C++Ḅconst5.2constî#defineḄïðC++QᵨconstᩭñQᵨ#defineᩭ஺TXòὅïSὅᨵÅIḄôõ¡1¥constᨵᦪö=÷¤øᨵᦪö=÷஺67ᘤQòὅù=÷úᐰüý஺Sὅþù°ÿᣚᨵᐰᙠᣚᧇᑮḄ┯▭ᦔ!஺2!ᨵ$%ᡂᓄḄ()*ᐹ,-const3456()78-93456()஺•ூ=ᑣ5-2-12ᙠC++ABCDEᵨconst34GEᵨ934ᓽconst34IᐰJK934஺5.334LM=ᑣ•ூ=ᑣ5-3-1௃◤⌕-᜜RSḄ34TᙠᜮᦻWC◤⌕-᜜RSḄ34TᙠLMᦻWḄᜮX஺YZ[\ᳮ,^_`ᙽḄ34%CbTᙠcdRᐳḄᜮᦻWC஺•ூ=ᑣ5-3-22᝞ghc34iᐸk34lᑗnᐵᙠLMCᒹqrsᐵtG

31uvc$wxḄy஺z᝞{constfloatRADIUS=100;constfloatDIAMETER=RADIUS*2;5.4CḄ34ᨵᡃh$34DᙠCᨵᦔ஺[#defineLMḄ9348ᐰḄᑮḄ[8ᯠᙢᵨconst¡⛲ᦪ¤ᡂᕒᩭ§¨஺constᦪ¤ᡂᕒḄ©8bᙠḄ7ᐸqMᓾ8ᡃᡠ¬Ḅ஺constᦪ¤ᡂᕒDᙠhd-b¬ᑁ834G-[᦮dG°ᓾ8±Ḅ²Y,³´µd-_Ḅ-ᐸconstᦪ¤ᡂᕒḄy,_஺ᙠ¶·C¸¹ᓄconstᦪ¤ᡂᕒ஺,ºᵨ»8┯Ḅ²YḄ-¼½³´¾¿ᘤÁ⍝SIZEḄy8ÄÅ஺classA(•••constintSIZE=100;//┯ÈÉᙠ¶·C¸¹ᓄconstᦪ¤ᡂᕒintarray[SIZE];//┯¼ÁḄSIZE)Ïconstᦪ¤ᡂᕒḄ¸¹ᓄDᙠ᪀⌼ÒᦪḄ¸¹ᓄ⊤C56z᝞classA{…A(intsize);//᪀⌼ÒᦪconstintSIZE;);A::A(intsize):SIZE(size)//᪀⌼ÒᦪḄ¸¹ᓄ⊤)Aa(100);//-aḄSIZEyY100Ab(200);//-bḄSIZEyY200Ù᪵Û´xᙠ᦮dCÜឤLḄ34ᕖßàᢣconstᦪ¤ᡂᕒâᵨCḄãä34ᩭ§¨஺z᝞classAenum{SIZE1=100,SIZE2=200);//ãä34intarray1[SIZE1];

32intarray2[SIZE2];!Ïãä34ᓰᵨ-Ḅbéêëkᙠ¾¿½ᐰXìy஺ãä34Ḅíî8:kḄ◚qᦪ¤8᦮ᦪᐸᨬᜧyᨵ▲⊤óôîᦪ᝞PI=3.14159!஺

33û6üÒᦪýþÒᦪ8C++/CABḄÿᓫᐗᐸ⌕ឋ஺ᦪḄ᧕ᦪ┯ᵨᡠ"ᐝ$ᦪḄ%&'(Ḅ஺)*+ᦪḄ,-.ᑁ012Ḅ345ᑣ஺ᦪ,-Ḅ78⌕9':ᦪ.;<=஺C>?ᦪḄ:ᦪ.;<=Ḅ@⌴BCᨵ7EF=@⌴(passbyvalue).ᢣ┐@⌴(passbypointer)C++>?IJKᵨ@o⌴(passbyreference)ᵫNKᵨ@⌴ḄឋOPᢣ┐@⌴$ᵨBCᓾP=@⌴RoSὅUUVWX᧕KYZ[\ᐜ▅_6.6⁚“Kᵨbᢣ┐Ḅcd”஺6.1:ᦪḄ5ᑣ•ூ5ᑣ6-1-12:ᦪḄiᑏ⌕k᦮⌕mnḕpqᑏ:ᦪḄrsḕᶍ:ᦪuv஺᝞xᦪyᨵ:ᦪᑣᵨvoidzᐙ஺|᝞FvoidSetValue(intwidth,intheight);//}~ḄvoidSetValue(int,int);//}ḄfloatGetValue(void);//}~ḄfloatGetValueO;//}Ḅ•ூ5ᑣ6-1-22:ᦪu⌕ា⌕ᔠᳮ஺|᝞ᑏvᦪStringCopy,ᨵ78:ᦪ஺᝞x:ᦪuvYstrl.str2,|᝞voidStringCopy(char*strl,char*str2);ᡃ'strlᑮstr2?'~᎔ᩭ஺¡":ᦪuvY¢£ᨵ¤¥᝞¦strSource.strDestination஺§᪵©uvª«¡"¬®strSourceᑮstrDestination«ᨵ38¯⚪§78:ᦪ38ᙠ²38ᙠ³´:ᦪḄ⌕⍳¶·ᕒḄ¹º஺3»ᙢ®½¾Ḅ:ᦪ¿ᙠ²☢Á:ᦪ¿ᙠ³☢஺᝞x½ᦪÂÃFvoidStringCopy(char*strSource,char*strDestination);ÄÅᙠ$ᵨÆ¡ÇᎷÉÊᙢᑏᡂ᝞ÌÍCFcharstr20;StringCopy(str,"HelloWorldw);//:ᦪÎ᎔•ூ5ᑣ6-1-32᝞x:ᦪ'ᢣ┐ÏÐÑÒᐭᵨᑣ®ᙠrs²Ôconst,"■Öᢣ┐ᙠᦪ×ᑁ¤᜜Ùᦋ஺|᝞F

34voidStringCopy(char*strDestination,constchar*strSource);•ூ5II6-1-42᝞xÒᐭ:ᦪ"=@⌴ḄBC@⌴ÛPᑣÜᦋᵨ“const&”BCᩭ@⌴§᪵¡"ḕÝÞÆÛPḄ᪀⌼.᪆᪀·©âãᦔ᳛஺æூçè6-1-12éêᦪᨵëIḄ:ᦪ:ᦪ8ᦪìíîᑴᙠ58"ᑁ஺᝞x:ᦪëIᙠ$ᵨÆ᧕½:ᦪrsᡈ┯஺æூçè6-1-22ìí⌕$ᵨrs.ᦪ¾&ñḄ:ᦪ஺C᪗óôᦪprintf'õᵨ&ñ:ᦪḄᐺs÷⊤ᐸùsFintprintf(constchat"format,argument1•,•);§EḄᦪᙠúÆûᜫJýḄrsþᐰ஺6.2Ḅᑣ•ூᑣ6-2-12⌕ḕᶍḄ஺CḄᦪᢥ᦮ᜐᳮ஺$᪵&'ᨵ)*+ᜐᓾ-᧕/012void஺C++ᨵ345Ḅ6ᐰᐕ9:;<=>?஺ᵫAC++BCDEFᵨCᦪ2HIJKLMNOC++/CᦪPQRᨵ஺᝞TᦪUᨵV*WX2void஺•ூᑣ6-2-2௃ᦪZ[\ᙠ^:D_`஺ab$ᩩᑣḄᐺe⊤gC᪗ijᦪgetcharok᝞lcharc;c=getchar();if(c==EOF)ᢥ᯿getcharZ[ḄnopqrcX2charg3ᯠḄt<஺uvḄggetcharḄwgcharxgintᐸz᝞{lintgetchar(void);ᵫAcgchar|~g-128,127,᝞TEOFḄᙠcharḄ|~᜜V*ifpgᜫ$“ᓻ◅”ᧇᑮk┯0ḄNᙠᵨᡝgᦪgetchar0Hᵨὅ஺•ூᑣ6-2-32⌕p┯0᪗Kᙠ¡஺ᵨ¢£¤ᦪ¥x┯0᪗ᵨreturn஺¦:kC᪗ijᦪḄ§¨ὅ2)*⌕pgetcharX2©ª«Ḅintᕖ

35®'V*¯ᔩᙠ<={getcharḄwᓫ¹[º஺u᝞Tgetchar»ᑮᦻ½¾¿᪗ᡈ>?Á┯0ÂQR¹᪗EOF஺2HÆÇAḄ[ºÈ+pEOFM^2Éᦪ(Ë2É1)஺ÎÏᦪgetcharÐᡂHint஺ᡃᙠÕ▭×ØÙ'»ᑮ:;©2ÚḄÛ⚪஺2HIJ£Ý01ᡃWÞp┯0᪗ᑖà஺ᓽlᵨ¢£¤ᦪ¥x┯0᪗ᵨreturn•ᦪgetcharDEᦋᑏᡂBOOLGetChar(char*c);ëᯠgecharìGetCharᮣîk᝞putchar(getchar());ug᝞Tgetcharᵨ┯H,ÂḄᮣîឋòᨵ)*ᵨᕖ©ூóô6-2-1]ᨵõ᎛ᦪz◤⌕u2Høᮣîឋ᝞ùᢝûü⊤ýDE▬஺k᝞[ºÿᦪstrcpyḄchar*strcpy(char*strDest,constchar*strSrc);strcpyᦪstrSrcᦪstrDest!"#ᦪḄ$%I'()strDest஺+᪵-./0123!4567᝞9ᮣ;ឋcharstr[20];intlength=strlen(strcpy(str,"HeHoWorld"));IூKL6-2-2]᝞MᦪḄ$%')•OPQ!ᨵSTᔠᵨ“XᵨY⌴”\ᣚ“'Y⌴”45^_ᦔ᳛஺bᨵSTᔠcdᵨ“'Y⌴”bedᵨ“XᵨY⌴”!ᔲᑣh┯஺j᝞classString(-//m'ᦪString&operate=(constString&other);//opᦪ!᝞Mqᨵfriends⛲ᑣcuᨵ2OvwᦪfriendStringoperate+(constString&sl,constString&s2);private:char*m_data;)StringḄm'ᦪoperate=Ḅ}~᝞9:String&String::operate=(constString&other)(if(this==&other)return*this;deletemdata;

36m_data=newchar[strlen(other.data)+l];strcpy(m_data,other,data);return*this;//$%Ḅ)*thisḄXᵨ!◤)Pm'ᦪ!ᵨ“XᵨY⌴”Ḅ$%StringPQ஺᝞Mᵨ“'Y⌴”Ḅ!ᯠdᯠ!ᵫreturn⌕*thisᑮ$%'Ḅ᜜ᓫᐗ!p¡e¢⌕Ḅ£├!¥¦¡m'ᦪḄᦔ᳛஺j᝞Stringa,b,c;a=b;//᝞Mᵨ“'Y⌴”!¨©2ª*thisa=b=c;//᝞Mᵨ“'Y⌴”!¨©«ª*thisStringḄopᦪoperate+Ḅ}~᝞9Stringoperate+(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;}Popᦪ!ᵨ“'Y⌴”Ḅ$%StringPQ஺᝞Mᦋᵨ“XᵨY⌴”!¶·ᦪ$%')2OᢣᔣºPQtempḄ“Xᵨᵫtempᙠᦪ¼½#¾¿À├Á!ÂÃ$%Ḅ“Xᵨ”ᦔ஺j᝞:c=a+b;1#a+b.e$%ÄÅ'!cÆ·Ç7eᑮ!È9¡◚Ê஺6.3ᦪᑁ}~ḄÌᑣe"dḄᦪᐸᑁ}~ᔜeo"!ÏÐᩭÒÓÔÕ“ᑁ}~”Öᡂ2ÃḄØÙ஺᪷ÛÜÝ!ᡃß45ᙠᦪàḄ“ᐭâᜐ”ä“âᜐ”åæᐵ!åb^_ᦪḄèé஺•ூÌᑣ6-3-1௃ᙠᦪàḄ“ᐭâᜐ”!PᦪḄᨵᦔឋëìíî஺ï0ð┯ñ)ᵫ/ÔᦪXÐḄ!ᡃßòᐙᑖᳮö.÷ᵨ“øù”(assert)ᩭ■û1ü┯ñ஺ýþ6.5⁚“ᵨ

37•ூᑣ6-3-2௃ᙠᦪḄ“ᜐ”returnḄ!"ឋ$ᦔ᳛'()*஺᝞-ᦪᨵ/0123ᦪḄ“ᜐ”4return஺ᡃ67⌕9:return஺᝞-returnᑏ<7=ᦪ⌕3┯⌕3ᦔ᳛?@஺ABC⚗᝞@E(1)return7I/0ᢣᔣ“᪘ᑁN”Ḅ“ᢣ┐”ᡈὅ“Rᵨ”STUᑁNᙠᦪVWXYZ[├]஺^᝞char*Func(void)(charstr[]="helloworld";//strḄᑁNqr᪘sreturnstr;//tuv┯w)(2)⌕yz{/0Ḅ|}4“1”ஹ“ᢣ┐”4“Rᵨ”஺(3)᝞-ᦪ/014⌕ὃ⇋returnḄᦔ᳛஺^᝞returnString(sl+s2);4XḄ⊤''X/0”஺7⌕T“ᐜtemp/0ḄV-”4Ḅ᝞Stringtemp(si+s2);returntemp;7ᯠsṹt¢£¤¥C஺✌ᐜtempY§X¨ᡂª«ᓄEᯠ®¯᪀⌼ᦪ²temp®¯ᑮ´N/01Ḅ᜜N¶ᓫᐗ¹ºᨬtempᙠᦪVWXY├](¼ᵨ᪆᪀ᦪ)஺ᯠ¾“X/0”Ḅ¿À47§ḄÁÂᘤÄŲXª«ᓄᙠ᜜N¶ᓫᐗ¹ḕÇÈ®¯$᪆᪀ḄᓄÉÊËÈᦔ᳛஺ÌÍᙢᡃ67⌕treturnint(x+y);//XÑÒ/0ᑏᡂinttemp-x+y;returntemp;ᵫrᑁᦪÕÌÖ᝞int,float,doubleḄÑÒ7Nᙠ᪀⌼ᦪ᪆᪀ᦪÚᯠU“XÑÒḄ”7ÛÊËÜÝᦔ᳛Þ4Àßàáâã᧕å஺6.4ᐸçèூç6-4-1௃ᦪḄéê⌕ᓫ7⌕ëìÜᵨ⌶Ḅᦪ஺èூç6-4-2௃ᦪḄî⌕ïðÒñᑴᙠ50(ṹôᑁ஺èூç6-4-3]ðÒõöᦪ÷ᨵ“øù”éê஺ú§ḄûᐭýþÿḄ஺ᨵ“”Ḅᦪᐸ⚜ḄḄ

38!“"᝱”஺$᪵Ḅᦪ&᧕ᳮ)*ᑭ,-./஺ᙠC/C++123ᦪḄstatic4567ᦪḄ“”89ᘤ஺;<=7>ᵨstatic4567◀AB◤஺Dூ;<6-4-4௃G⌕IJᐭLᦪḄᨵᦔឋO⌕IJPQᐸ⌶STᐭᦪUᑁḄ67ḄᨵᦔឋW᝞ᐰ467ஹᦻ\]^_஺Dூ;<6-4-5ᵨ┯ᜐᳮḄbcdef⌕ghijᵨὅl᧕mnᡈp)┯pqr஺6.5jᵨs2tuevᑖDebug᱐y-Release᱐yDebug᱐yᵨᑁ5z,Release᱐y{|ᵨᡝjᵨ஺s2assertGᙠDebug᱐y~ᵨḄᵨIJ“”{Ḅqr஺W6-5eᑁ8ᑴᦪ஺ᙠQt3᝞assertḄLᦪᎷtu3evᙢOᙠᙢ{assert஺void*memcpy(void*pvTo,constvoid*pvFrom,size_tsize)(assert((pvTo!=NULL)&&(pvFrom!=NULL));//jᵨs2byte*pbTo=(byte*)pvTo;//■ᦋ6pvToḄᙢᙬbyte*pbFrom=(byte*)pvFrom;//■ᦋ6pvFromḄᙢᙬwhile(size—>0)*pbTo++=*pbFrom++;returnpvTo;}W6-5ᑴḄᑁ8ᙽasserte¢£¤¥~ᩭḄ஺ᙠtuḄDebug᱐y-Release᱐y~§¨assert©ª«¬ᵨ஺ᡠ®assertᦪ¯஺tuᕒ®±assert²ᡂeᙠª«´µ"᝱¶·®¸ᐰjᵨḄ¹º,»¼஺᝞tuᙠassertᜐ½¾¿ᨵassertḄᦪᨵ┯p¯zᵨὅ§┯assert®ÀÁᡃÃÄᑮ{┯pḄÆ஺Ç>ᨵÈÉÊᑮtuḄs2ᓾÌ⍝s2ḄᵨÎiÏÐÑḄÒ஺ÓᓄÇÕÖ×᣸◀┯p¯ÙÚgh$┯pᑮÛ஺ᨵḄÖ᎛tuᕒᏔÞOßàᨵ┯pḄs2஺ᡠ®᝞ághs2IJḄÇâᑨs┯pᙠtu3Oᙠs23஺äḄ$å⚪Çç)Ù⌕èégᨎḄëìᓽ஺$yî¯᧕ïḄÒqÇ>ᨵtuᕒ$᪵ð஺$çÈeÏᙠñ᪍ó²ᑮ᪛é┑Ḽeᙽ“ᓻ◅”Ḅᜧúû஺üᓻ◅ᑮÛý᪛⌕᎔ýᨵÿᨵ◀“ᓻ◅”ᔲᑣᑮ᩽ᨵᦔḄ!ᵨ஺ᳮ%Ḅ&'(()*+ᕒ-ᶍ/0)ᑤ◀஺Maguire,p8-p30

39•ூ5ᑣ6-5-126ᵨ&'ᣓᣍ9:;<=Ḅ>?@஺9⌕BC>?@D┯F?@GHḄIJKὅMᯠOᙠḄQRST⌕!UᜐᳮḄ஺•ூ5ᑣ6-5-22ᙠWᦪḄᐭZᜐ6ᵨ&'[\]ᦪḄᨵᦔឋ_ᔠ>ឋa஺•ூbc6-5-12ᙠdᑏWᦪf⌕ghijḄὃ\QRlmn“ᡃᡭqrstᎷT”SvwTxḄᎷTy⌕6ᵨ&'zᎷTgh[\஺•ூbc6-5-22S{ᦟ}~*+ᕒgh■┯⌕d*◚Ṱ┯F஺gh■┯f᝞“9<=”Ḅ?Ḅw<=xᑣ⌕6ᵨ&'gh஺6.6ᵨDᢣ┐ḄᵨC++Ḅᭆὅ¡᧕£ᵨ¤ᢣ┐BCS஺S¥*+nmḄSᵨ_referencea,m)ᵨᱥ_referenta஺intm;int&n-m;n±²mḄJ³_´µaznḄ¶·¸!yzmḄ¸!஺¹᝞ᨵ³º»¼½¾Ḅ´µ“¿½”஺À“¿½”ÁÁḄᐸÃyz»¼½À¿⍝Å஺ᡠnÇ9mḄÈÉÊ9ᢣᔣmḄᢣ┐ᐸÃnymÌlÍ஺ᵨḄSt5ᑣ᝞¥n_1aᵨ)ÏbḄÐfMÑ)Òᓄ_ᢣ┐ᑣᙠ¶·f᎛)Òᓄa஺_2a9ᨵNULLᵨᵨMÑDᔠ>ḄOÙᓫᐗᐵὶ_ᢣ┐ᑣNULLa஺_3aSvᵨ)Òᓄy9ᦋàᵨḄᐵá_ᢣ┐ᑣâfᦋàᡠᢣḄzãa஺¥ä¹*+k)ÒᓄæiḄᵨ஺çèk=jQ9ëkìᦋᡂæjḄᵨî£kḄïᦋàᡂæ6஺ᵫ²kiḄᵨᡠiḄïÊàᡂx6஺inti=5;intj=6;int&k=i;k=j;஻1õ¤iḄïàᡂx6:÷☢Ḅ*+ùᩭãᙠûᦻýþÿᨵᵨḄ஺ᵨḄ⌕⌴ᦪḄᦪ஺C++ᦪḄᦪḄ⌴ᨵ!"⌴ஹᢣ┐⌴ᵨ⌴஺&'“⌴”Ḅ*+,-஺ᵫ/FunclᦪᑁḄx᜜89:nḄ;<=>ᦋ9xḄ@ABCn,ᡠ&nḄFᯠ0஺voidFunclNintxPx=x+10;}

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

41Ö7Çᑁᳮ×ØÙᐭᑁᱏÜÝ஺ÞᜧḄBillGatesãäᜫ"640Koughttobeenoughforeverybody—BillGates1981,-ᕒóäôᑏᑁᳮ,-õõö÷øù஺᝞±@úûÜü•ḄþÿᡠᨵḄᙢ᣸◀Ḅ஺Ḅᑁᦟ!Ḅ⌕#ᐭ%&'ὅ◤*+▅'-ᑮ/0ᙢ1᧽ᑁ34ᳮ஺7.1ᑁ3ᑖ89:ᑁ3ᑖ89:ᨵ;<=(1)A☟᝱3DEFᑖ8஺ᑁ3ᙠHIJKḄL᎛NOᑖ8PQᙽᑁ3ᙠHIḄ᦮TUVWXY3ᙠ஺Z᝞ᐰ]^_static^_஺(2)ᙠ᪘ghi஺ᙠ᡻VkᦪLkᦪᑁ]m^_Ḅ3DᓫᐗYpqᙠ᪘ghikᦪ᡻VrsLQt3Dᓫᐗuvwxy஺᪘ᑁ3ᑖ8Uzᑁ{|ᜐᳮᘤḄᢣᦔ᳛ᑖ8Ḅᑁ3_ᨵ▲஺(3)Aᚮgᑖ8v᝱ᑁ3ᑖ8஺HIᙠUVḄL᎛ᵨmallocᡈnewᵭ&Ḅᑁ3HIᕒuᙠLᵨfreeᡈdeletexyᑁ3஺v᝱ᑁ3Ḅ¢3Wᵫᡃ¥¦§ᵨ¨©ᮣ«¬⚪®ᨬ&஺7.2©°Ḅᑁ3┯²³ᐸµ¶¢ᑁ3┯²·¨©¸¹Ḅº»஺JKᘤ¼uvQt┯²1©ᙠHIUVL½¼ᣓᣍᑮ஺ÀQt┯²ᜧ&ÂᨵÃÄḄÅÆL◚LÈÉᦋ┯ḄËÌ஺ᨵLᵨᡝ᝼ÏÐÐᙢÑÒÓᩭHIᓾÂᨵ¢¬⚪ÒÖ┯²×Ø஺©°Ḅᑁ3┯²³ᐸµ¶᝞Ù=♦ᑁ3ᑖ8ÚᡂÜᓾ§ᵨ஺JHÝÞ©ßQ<┯²àáâÂᨵãᑮᑁ3ᑖ8äᡂÜ஺©ᵨå¥ᙠ§ᵨᑁ3æçèéᢣ┐ᔲáNULL஺᝞ïᢣ┐pkᦪḄñᦪòóᙠkᦪḄᐭôᜐᵨassert(p!=NULL)÷Vèé஺᝞ïᵨmallocᡈnewᩭᵭᑁ3øùᵨif(p==NULL)ᡈif(p!=NULL)÷V■┯ᜐᳮ஺♦ᑁ3ᑖ8ûᯠᡂÜýÚþÿᓄᵨ஺┯⌕ᨵᨵᓄḄᑁḄ!ḕ#ᐰ%&'(ᵨ#┯(*᝞ᦪ-)஺ᑁḄ!ḕ#/0123ᨵ4Ḅ᪗6&78ᨵ9:᎛%#&ᡃ=>?@

42ᐸCD?@ᐸᨵ஺ᡠCFᵨGHIJKᦪ-&LMNOP#&ᓽRP%#SD?ḕᶍ&D⌕UVW஺♦ᑁᑖYᡂ[3\]^ᓄ&_`abcOᑁḄde஺*᝞ᙠgᵨᦪ-:^hijk᪗“m1”ᡈὅ“p1”Ḅ`a஺ᱯMᙠforrstuv&rswᦪxy᧕{┯&'(ᦪ-`abe஺♦N|O}~ᑁ&⌼ᡂᑁ☄஺ᨵ┯Ḅᦪᵨwᜫᙽᑁ஺:4Ḅᑁᐙ&Dᑮ┯஺ᨵwᯠᣵ&4ᑁὑ7஺᝱ᑁḄᵭ¡¢}~£¤Y¥&vmalloc¢freeḄgᵨwᦪ¦⌕§¨&ᔲᑣ«¦ᨵ┯¬new/delete¨ᳮ®஺♦}~Oᑁᓾ°±gᵨ஺ᨵ²³´¬1®vḄ¥µᵨᐵc·¸ᩖ&ºᙠ»{¼½¾¥µ/0ᔲ]^}~Oᑁ&¿:ÀÁÂÃÄÅᦪÆÇ᪀&É᪷ËÌÍÎ¥µ8ᳮḄÏÐÑ☢஺¬2ᦪḄreturntuᑏ┯O&ÔÕD⌕Ö×ᢣᔣ“᪘ᑁ”Ḅ“ᢣ┐”ᡈὅ“ᵨ”,ÁᑁᙠᦪÞÇß:à├â஺3gᵨfreeᡈdelete}~Oᑁã&ᨵäᢣ┐ÄåNULL஺'(æj“çᢣ┐”஺•ூêëIJ7-2-12ᵨmallocᡈnewᵭ¡ᑁìã&ÀÁíᓽîïᢣ┐#ᔲNULL.■ñgᵨᢣ┐#NULLḄᑁ஺•ூêᑣ7-2-2௃D⌕N|ᦪ-ó᝱ᑁP#஺■ñäôᓄḄᑁaõ#gᵨ஺•ூêᑣ7-2-32ö÷ᦪ-ᡈᢣ┐Ḅk᪗be&ᱯM⌕øùij“m1”ᡈὅ“p1”`a஺•ூêᑣ7-2-42᝱ᑁḄᵭ¡¢}~£¤Y¥&■ñᑁú஺•ூêᑣ7-2-5௃ᵨfreeᡈdelete}~Oᑁìã&íᓽäᢣ┐ÄåNULL,■ñæj“çᢣ┐”஺7.3ᢣ┐¢ᦪ-Ḅ¥ûC++/Cv&ᢣ┐óᦪ-ᙠDpᙢH?§ýþᣚḼᵨ┯ὅḄ஺ᦪ⌕ᙠ☟᝱!᝞ᐰ$ᦪ%⌕ᙠ᪘'஺ᦪ()*Ḽ!+,ᢣᔣ%ᙽᑁᐸᙢᙬ456ᙠ78ᑁ9ᢝ,;<ᨵᦪḄᑁ5>ᦋ;஺ᢣ┐>ABᢣᔣCDEFḄᑁᙽGḄᱯI“>;”ᡠᡃNOᵨᢣ┐ᩭQRS᝱ᑁ஺ᢣ┐TUᦪᮣWXYZᓻ◅஺

43^☢`abcUdᢣ┐4ᦪḄᱯឋ஺7.3.1fᦋᑁ5gc7-3-1l`aᦪaḄ566o`aᐸᑁ5helkAO஺aḄᑁ5>ᦋ;,᝞a[0]=ᢣ┐pᢣᔣO6`ab“world”(☟᝱ᑁ5world'஺)O6`abḄᑁ5,>fᦋḄ஺'ᘤ,p[OJ=Xᨵ,XfᦋO6`abḄᑁ5+┯஺chara[]="hello”a[0]='X';cout<ᐜᵨ»¼ᦪmallocpᵭÌᙽ56strlen(a)+lo`aḄᑁÎᵨstrcpy¬`abªᑴ஺¿ᳮif(p==a)UdḄ,ᑁ5+ᙢᙬ*ᵨ»¼ᦪstrcmpᩭUd஺//ᦪ…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)gc7-3-2ᦪ©ᢣ┐Ḅᑁ5ªᑴ4Ud

447.3.3[Tᑁ\]ᵨÑasizeof>ÒÑÓᦪḄ56(`⁚ᦪ)஺gc7-3-3(a)lsizeof(a)ḄÕ12(¥DÖ×Éᢣ┐pᢣᔣa,Xsizeof(p)ḄÕᓾ4஺ÚÛsizeof(p)ᑮḄoᢣ┐;6Ḅ`⁚ᦪÁÝsizeof(char*),+,pᡠᢣḄᑁ56஺C++/Cßàᨵáâ⍝ᢣ┐ᡠᢣḄᑁ56◀åᙠᵭÌᑁBæçG஺^_`ᦪ,abᦪḄcᦪdQe⌴gYhᦪ,ij⌨ᓄbm#nḄᢣ┐஺rs7-3-3(b)l,èᦪaḄ56éêsizeof(a)ëìsizeof(char*)஺chara[]="helloworld”;char*p=a;cout<

45ABCᙠEᦪGetMemoryF஺HIᘤK⌕EᦪḄNO9ᦪᑴQRSTUVᢣ┐9ᦪPḄTU_p,HIᘤY_P=P஺᝞[Eᦪ\ᑁḄ]^_ᦋa_pḄᑁbVcde9ᦪPḄᑁbQfgḄ_ᦋ஺hcᢣ┐ijᵨQkC9ᦪḄlm஺ᙠU3FV_pᵭ

46ᵨEᦪ«¬ᩭ¯⌴=᝱ᑁ@h±²³ºᯠ»ᵨVu¼¼ᨵ½preturn¾¿ᵨ┯a஺hÀÁÂz⌕ᵨreturn¾¿«¬ᢣᔣ“᪘ᑁ@”Ḅᢣ┐Vmᑁ@ᙠEᦪÄÅSÆ=ÇÈV237-4-4஺char*GetString(void)(charp[]="helloworld”;returnp;//HIᘤÎÏCÐÑ}voidTest4(void)(char*str=NULL;strGetStringO;//strḄᑁbᚗÔcout<

477.5freeúdeletepᢣ┐àᖾüýfreeúdeleteḄþãូḄ(ᐸdelete),ᢣ┐ᡠᢣḄᑁᣵᨵᢣ┐ᣵ஺ᵨ#$ᘤ&'()7-5,-.ᢣ┐p0free34ᐸᙢᙬ7ᯠ9:(;NULL),?ᙢᙬ@AḄᑁᚗCpᡂE“Hᢣ┐”஺᝞KLM9pNOPNULL,QRST3PpUᔠWḄᢣ┐஺᝞KXYZ[\ᡃᨵM^9_pᡠᢣḄᑁᔲab0ᙠdefᵨpghijQᵨklif(p!=NULL)pq■┯ᜐᳮ஺v⍡xLMifkly9ᑮ■┯{ᵨ|Pᓽ~p9NULLᢣ┐9ᢣᔣᔠWḄᑁᙽ஺char*p=(char*)malloc(100);strcpy(p,"hello");free(p);஻pᡠᢣḄᑁ0pᡠᢣḄᙢᙬ7ᯠ9:if(p!=NULL)//ᨵyᑮ■┯{ᵨ(strcpy(p,"world");//┯()7-5pᡂPHᢣ┐7.6᝱ᑁQ0ᔩᦪᑁḄ:ᙠᦪM஺v¡ST3P()7-6£¤Ḅ஺ᳮᵫpḄᢣ┐:ḄM᎛QRᡠᢣḄ᝱ᑁ§y¨©஺ª┯«¬voidFunc(void)(char*p=(char*)malloc(100);//᝱ᑁQᔩ}()7-6$²R᝱ᑁᡃ-.ᢣ┐ᨵ§³“´µ;”Ḅᱯ·¸(1)ᢣ┐&'()*+⊤-.ᡠᢣḄᑁ1234567஺(2)ᑁ1367()*+⊤-ᢣ┐2&'ᡈὅᡂ(NULLᢣ┐஺ª⊤ºᑁ9§»¼3₝᳛@¿ḄÀ஺ÁᨵS9ÂçÄ⌕Ƽ3₝᳛qÀḄᳮᵫ¸᝞KXYÇÈEÉq§ᑗᢣ┐ËQ᝱ᑁQ0Ì{ÍÎÏᦈ஺Ñᯠ᝞L,

48ᙠXYÒÇhÓ¼39Ôᑁஹ9ÔÖᢣ┐NOPNULLE஺Ç×¼3ᏕÙµ9Q-Ú┯TEᔳÜÝÞ஺᝞KßSàáXYâᩭᵨᑮᐸᙢäåæç7.7èé“Hᢣ┐”“Hᢣ┐”9NULLᢣ┐ᢣᔣ“ᚗC”ᑁḄᢣ┐஺S§ê9Q┯ᵨNULLᢣ┐|Pᵨifklvë᧕ᑨî஺“Hᢣ┐”vᓻ◅Ḅifkl@9y{ᵨ஺“Hᢣ┐”Ḅᡂ|ñ⌕ᨵòó¸(1)ᢣ┐:ᨵ0ôõᓄ஺÷øᢣ┐:ù0úûM9QᡂPNULLᢣ┐ḄüḕþÿḄᢣ஺ᡠᢣ┐ᙠḄᓄ⌕ᢣ┐NULL,⌕$ᢣᔣᔠ'Ḅᑁ)஺*᝞char*p=NULL;char*str=(char*)malloc(100);(2)ᢣ┐pfreeᡈὅdeleteDEFᨵNULL,$HIpJKᔠ'Ḅᢣ┐஺LM7.5⁚஺(3)ᢣ┐STUVWḄTᵨZ஺[\]^$H■`a■b*cd᝞efclassA(public:voidFunc(void){cout<<"FuncofclassA”<Func();஻pJ“ᢣ┐”)ᦪTestᙠ᡻p->Func()aᜫpJᢣᔣaḄᡠpᡂW“ᢣ┐”஺᜻ḄJᡃ[KcdᯠFᨵ┯[ᘤᨵᐵ஺

497.8ᨵWmalloc/free¡⌕new/delete?mallocfreeJC++/C¢Ḅ᪗¤¥ᦪnew/deleteJC++Ḅ¦§஺¨©ᵨªᵭ¬᝱ᑁ)¯°±ᑁ)஺ª²ᑁ³ᦪ´µ¶Ḅ¢ᐝᵨmaloc/free¸'¹º᝱Ḅ⌕»஺ᙠḄ⌕¼᡻᪀⌼ᦪᙠ¿DÀ⌕¼᡻᪆᪀ᦪ஺ᵫªmalloc/freeJ¥ᦪ`J¦§`ᙠᘤÃᑴᩗ▲Dᑁ`ÇÈ᡻᪀⌼ᦪ¯᪆᪀ᦪḄÉÊË̪malloc/freeoÍÎC++¢◤⌕KÐᡂ᝱ᑁ)ᑖÒ¯ᓄÓTḄ¦§new,ÔKÐᡂÕᳮ°±ᑁ)ÓTḄ¦§deleteovwnew/delete`J¥ᦪ஺ᡃ¨ᐜØØmalloc/free¯new/delete᝞ÙÚÛḄ᝱ᑁ)ÜᳮMb*7-8஺classObj(publicObj(void){cout<<"Initialization”<Initialize();//ᓄ//...a->Destroy();//Õ◀ÓTfree(a);//°±ᑁ)}voidUseNewDelete(void)(Obj*a=newObj;//ᵭ¬᝱ᑁ)Þßᓄ//...deletea;//Õ◀Þß°±ᑁ)}b*7-8ᵨmalloc/free¯new/delete᝞ÙÚÛḄ᝱ᑁ)ÜᳮµObjḄᦪInitializeàáW᪀⌼ᦪḄâᦪDestroyàáW᪆᪀ᦪḄâ஺ᦪUseMallocFreeãäªmalloc/free`᡻᪀⌼ᦪ᪆᪀ᦪåæçᵨᡂᕒᦪInitialize¯DestroyᩭÐᡂᓄÕ◀ÓT஺ᦪUseNewDeleteᑣëᓫíî஺

50ᡠᡃ¨`⌕ïðᵨmalloc/freeᩭÐᡂ᝱Ḅᑁ)Üᳮñᵨnew/delete஺ᵫªᑁ³ᦪ´µ¶Ḅ“”Fᨵ᪀⌼᪆᪀Ḅóc¨¢malloc/free¯new/deleteJôõḄ஺öᯠnew/deleteḄâÐᐰ⌚ùWmalloc/free,C++`Èmalloc/freeüýþᕖC++⌕ᵨCᦪCᵨmalloc/freeᳮ᝱ᑁ"஺᝞%ᵨfree&'"new+,Ḅ᝱./”123./45᡻7᪆᪀ᦪ:;<=┯஺᝞%ᵨdelete&'"mallocᵭBḄ᝱ᑁ"”ᳮCDEFG=┯H3Ḅ:IឋKL஺ᡠNnew/deleteOPQ.Rᵨmalloc/freeST-᪵஺7.9ᑁ"ὑXY2Z᝞%ᙠᵭB᝱ᑁ"\]Fᑮ_`ᜧḄᑁ"ᙽmalloccnewdefNULLᢣ┐lmᑁ"ᵭBᜫo஺pᨵrstuᜐᳮ“ᑁ"ὑX”x⚪஺(1)ᑨ~ᢣ┐ᔲNULL,᝞%ᑣDᵨreturnᦪ஺᝞voidFunc(void)(A*a=newA;if(a==NULL)(return;))(2)ᑨ~ᢣ┐ᔲNULL,᝞%ᑣDᵨexit(l)᦮Ḅ7஺᝞voidFunc(void)(A*a=newA;if(a==NULL)(cout<<"MemoryExhausted^^<

51ᳮᦪ஺¯°ᑁ±B²ὃC++Rᵨ´µ஺D¶·1¸·2¸tuRᵨᨬº»஺᝞%Tᦪᑁᨵ¼ᜐ◤⌕ᵭB᝱ᑁ"12tu·1¸¾¿ÀÁFÂ÷&'ᑁ"KÄŸÆ3ᵨtu·2¸ᩭᜐᳮ஺K¼ÈFÉÃᵨexit·l¸,x“FÊᑏ=┯ᜐᳮªÌÍÎϦ§ÐÑ7F7”F7஺᝞%ÒÓ“ᑁ"ὑX”᪵ḄÔÕTÖ×ᩭÆᵨØ4Ù:ᦗ஺᝞%Fᵨexit·l¸ÛÜᩔÞß:GàÞÌÍÎÏ஺⍝ᳮ᝞®᝞%FÛâãäåâãᙠὁÞçèGéêë¼Ḅì஺ᨵTKí⌕Ḅî/⌕mïᜧð஺.ñ32òNDḄÆᵨó4CY᪵Rᵨmalloc¬new,ôõF:;<"ᑁ"ὑX"஺ᡃᙠWindows98êᵨVisualC++Êᑏúûüýþ7-9஺ᙢ᪷஺32ᢝ“!"”ᑁ"ᵨ&'()ᵨ*+,-⚔/஺ᡃ12ᑮ*+4ᔷ4ᔷᙢ6Window98?@ABCD+ஹF᪗HIJ஺ᡃKLBMNOPQRCS32LTḄJᵨ“ᑁ"ὑW”┯YᜐᳮHᵨᜐ஺K\Unix_Windowsᕒbcd'RIe┯Yᜐᳮfᵨᡃgᑏ'ḕ'jklm஺ᡃnYopὅrstuRv┯YᜐᳮwoxḄyzj{ᓟ}K~ᜫᜧ஺voidmain(void)(float*p=NULL;while(TRUE)(p=newfloat[1000000];cout<<"eatmemory”<

52ᡃbJ¶\·¸¹º»ᙠ½⌕¾TR“´ª¿ᣚ”_“sizeof”஺♦mallocÁÂÃḄ´ªÄvoid*,ᡠLᙠuᵨmallocÆ⌕ÇÈᙢÉ´ª¿ᣚwvoid*¿ᣚᡂᡠ◤⌕Ḅᢣ┐´ª஺♦malloc§ᦪÎÏÐÑ⌕ᵭ®Ḅᑁ"ÄÒN´ªÓ1ᐵÕᑁ"ḄÖ×⁚ᦪ஺ᡃbÙÚÛÜint,floatÝᦪÞ´ªḄßzḄàᑗ×⁚ᦪ஺᝞intßzᙠ16Ä2×⁚ᙠ32Ä4×⁚âãfloatßzᙠ16Ä4×⁚ᙠ32äÄ4×⁚஺ᨬæᵨLOçè¢Rcout<int*pl=(int*)malloc(sizeof(int)*length);int*p2=newint[length];?@AnewᑁBCsizeof,EFGᣚIEFJᐰLMN஺OPᑁQᦪREFḄSTUnewᙠWXY᝱SḄ[\]ᡂC_`ᓄb஺᝞Sᨵd᪀⌼8ᦪnewḄghiᨵjkl஺=᝞classObj{public:Obj(void);//oᦪḄ᪀⌼8ᦪObj(intx);//pqdoᦪḄ᪀⌼8ᦪ

53}voidTest(void)Obj*a=newObj;Obj*b=newObj(1);//_sA1deletea;deleteb;)᝞ᵨnewWXSᦪuv/ᵨSḄoᦪ᪀⌼8ᦪ஺=᝞Obj*objects=newObj[100];//WX100dY᝱SᑏᡂObj"objects=new0bj[100](1);//WX100dY᝱SḄ[\x_s1ᙠᵨdeleteSᦪu\ᶇz⌕{C4|'~=᝞delete[[objects;//Ḅᵨdeleteobjects;//┯.ḄᵨὅOdeleteobjects[0],ᣵC᜜99dS஺7.12q<ᡃᢈ┯ḄC++/C)*ᕒᨵ᧽ᢣ┐ᑁᳮ(ᒹᡃ)஺ᡃᨬ_¢£CU\ᱯ¥᝿ᢣ┐'(ᡃ§¨©qdªᵨ«¬(1®,C¯ṹ)\±ᨵ/ᵨqdᢣ┐ᐰᵨᦪuᩭ⚔³ᢣ┐´ᙠ≶¶<·ᑖ஺¹ºᢣ┐»ᩭᡃᦋᑏC?d«¬¯ṹ½¾¿ᑮÁᐜḄqÃ஺ᡃḄÄÅᦟÇ>(1)È᝿ᢣ┐&È⌕/ᵨᢣ┐஺/ᵨᢣ┐ÉÊ3ËᔠÍḄ)*ᕒ஺(2)ÎÏÐᡂ“/ᵨÒÓᘤ⌲Ö×Ø)*”Ḅ£Úvᨵ?᪵ܨÝ!⚪ḄÞß஺

54©8àC++8ᦪḄáâᱯឋ7OCUḄ8ᦪ,C++åæCçèéoverloadedஹᑁὶéinlineஹconstIvirtualìjíîᑴ஺ᐸñçèIᑁὶîᑴòhᵨOᐰó8ᦪghᵨOEḄᡂᕒ8ᦪconstvirtualîᑴôᵨOEḄᡂᕒ8ᦪ஺çèIᑁὶÉÊᨵᐸõᜐÜ÷C++UøùúhiᡂûüḄᓤ⚶Tÿᵨ஺ᑁὶḄ▲ឋᵨஹᵨ!⌕#$┯ᵨ஺8.1'ᦪḄᭆ*8.1.1Ḅ+,-ᯠ/012345ᨵ789Ḅ:;ᓽ4=>஺?@5ABCᦻᩭᑨG4ᑮIJKL:;஺“4Ḅ”5O/0PQRS஺T᝞“ᔛW”Ḅ:;ᓝᑖZ[?@\ᨵ]⌕^_`abcᐹeᔛ5஺fgῖaijkl₎✏oḄ₎pᨵqLᑏs஺ᙠC++uv15/;ஹwxyzḄ{3'ᦪᵨ923|p⊤~ᓽ'ᦪ஺᪵>'ᦪḄ᧕ᵨឋJC++/0ᵨᑴḄ23ᳮᵫ஺T᝞~T8-1-11Ḅ'ᦪEatBeef,EatFish,EatChicken5ᵨ923'ᦪ|Eat⊤~ᵨ9ḄᦪQf஺voidEatBeef(•,,);//5ᦋvoidEat(Beef…)voidEatFish(•,,);//5ᦋvoidEat(Fish…)voidEatChicken(•)//5ᦋvoidEat(Chicken…)~T8-1-1'ᦪEatC++/0ᵨᑴḄ2-3ᳮᵫJḄ᪀⌼'ᦪ◤⌕ᑴ஺C++᪀⌼'ᦪ9|9¡᪀⌼'ᦪ¢xᨵ23|p஺᝞£¤ᵨ{L9Ḅ¥s¦§¨i©ª«f¬⌱®¢xᵨᑴᩭ¯°஺ᡠ5ᨵ839|Ḅ᪀⌼'ᦪ஺8.1.2J᝞²¯°Ḅ«{39|Ḅᡃ'ᦪ´ᯠJ9Ḅ'ᦪµ@J᝞²ᑖḄᕖ«ᡃ@-ᯠ¤ᑮ'ᦪ·¸Ḅ¹3⌕ºᦪ»¼½஺᝞£9|'ᦪḄᦪ9ᒹ¿ஹÀv9¡ÁÂ᧕fõ@J9Ḅ'ᦪ஺

55᝞£9|'ᦪÄÄJ»¼½9ᨵÅ5ᑖᨵÅᓾx஺T᝞voidFunction(void);intFunction(void);Cǹ3'ᦪ23\ᨵ»¼½È3Ḅ»¼½Jint஺᝞£᪵Éᵨ'ᦪintx=Function();ᑣ5ᑨGÃFunctionJÈ3'ᦪ஺Ë⚪JᙠC++/Cuv1ᡃ@5Íᶍ'ᦪḄ»¼½஺ᙠLÏÐᘤuvᕒÓÔ⍝K3Function'ᦪ=Éᵨ஺ᡠ¢x☠ᦪ×x☠»¼½Ḅ9ᩭᑖ'ᦪ஺ÏÐᘤ᪷Ùᦪ^3'ᦪÚÛ9ḄᑁÜ᪗Þß஺T᝞ÏÐᘤ~T8771Ḅâ3Eat'ᦪÚÛieatbeefஹeatfishஹeatchickenãḄᑁÜ᪗Þß(9ḄÏÐᘤ5xÚÛ9åæḄᑁÜ᪗Þß)஺᝞£C++uv⌕Éᵨkç=ÏÐèḄC'ᦪ©ª«Ꮇêë3C'ᦪḄì᝞voidfoo(intx,inty);'ᦪ=CÏÐᘤÏÐèᙠí1Ḅ|p2f஺஺×C++ÏÐᘤᑣîÚÛi_foo_int_intãḄ|pᵨᩭðᢝ'ᦪòᐰô·஺õÏÐèḄ|p9C++uvxö·ÉᵨC'ᦪ஺C++÷>23Cô·øᣚᢣßûextern“C”ᩭüý3Ë⚪஺T᝞extern"C"(voidfoo(intx,inty);…//ᐸᦪ)ᡈὅᑏᡂextern"C"(ttinclude"myheader.h"…//ᐸCᜮᦻ)C++ᘤᦪfooCᑮ!"#foo$%_foo_int_intoC++ᘤ&'ᖪ)*+C᪗-Ḅᜮᦻ/0extern“C”ᜐᳮᡠ5ᡃ785ᵨ#include;<ᵨ=ᜮᦻ஺?@A%BᦪḄ!"CDE᪀ᡂGH஺ᐰJᦪKLḄᡂᕒᦪD!%NGHOPᦪḄ/ᵨQ%D஺R᝞TvoidPrint(•,•);//ᐰJᦪclassAvoidPrint(-);//ᡂᕒᦪ

56%UBPrintᦪḄ[ᦪᔲ%D᝞]LḄ^ᡂᕒᦪ⌕`ᵨᐰJᦪPrint,P0bᡂᕒᦪPrintcdᐰJᦪe`ᵨfg'TT'᪗i஺᝞::Print(-);//⊤nPrintᐰJᦪ$oᡂᕒᦪ8.1.3pq◚sLtuᣚwxGHᦪyz{|ឋnR8T-3#outputᦪḄ[ᦪintLt{outputᦪḄ[ᦪfloatLt஺ᵫᦪ"ᨵLtᦪ"p/[ᦪfLtuᣚ(P◚sLtuᣚ)஺஺utput(0.5)yz┯OPᘤ%⍝0.5uᣚᡂintfloatLtḄ[ᦪ஺◚sLtuᣚᙠᙢ¢85£ᓄ¥¦Ḅ§ᑏ¨©8Eᶇ«◚¬஺#includevoidoutput(intx);//ᦪ·¸voidoutput(floatx);//ᦪ·¸voidoutput(intx)(cout«"outputint"<

578.2ᡂᕒᦪḄGHஹ⌚Äb◚ÅᡂᕒᦪḄGHஹ⌚Ä(override)b◚ÅÆ᧕ÈÉC++¥¦ᕒÌÍ⌕ÎÏÐᭆÒᔲᑣ┯■%Õ■஺8.2.1GHb⌚ÄᡂᕒᦪeGHḄᱯ×T(1)CDḄÙ(ᙠD#L)Ú(2)ᦪ!"CDÚ(3)[ᦪ%DÚ(4)virtualᐵÞ"8ᨵ8ß஺⌚ÄᢣázLᦪ⌚ÄâLᦪᱯ×T(1)%DḄÙ(ᑖdäázLbâL)Ú(2)ᦪ!"CDÚ(3)[ᦪCDÚ(4)âLᦪÌÍᨵvirtualᐵÞ"஺nR8-2TᦪBase::f(int)bBase::f(float)CæGH,$Base::g(void)eDerived::g(void)⌚Ä஺ttincludeclassBase(public:voidf(intx){cout<<"Base::f(int)”<ீx<f(42);//Base::f(int)42

58pb->f(3.14f);//Base::f(float)3.14pb->g();//Derived::g(void))nR8-2-1ᡂᕒᦪḄGHK⌚Ä8.2.2tuvwḄ◚yᑣᩭññcdGHb⌚ÄA%Nòó¨C++Ḅ◚Åôᑣõö⚪øᩖឋ▽ᯠüg஺ý“◚Å”ᢣázLḄᦪþÿᐸḄᦪᑣ᝞(1)᝞ḄᦪḄᦪᦪ஺ᨵvirtualᐵ()Ḅᦪ*+◚-(./01234)஺(2)᝞ḄᦪḄᦪ67ᦪ89ᦪ:ᨵvirtualᐵ()஺Ḅᦪ+◚-(./0⌚<34)஺=>?@8-2-2(a)D(1)ᦪDerived::f(float)⌚<Base::f(float)o(2)ᦪDerived::g(int)◚-Base::g(float),P12஺(3)ᦪDerived::h(float)◚-Base::h(float)5P⌚<஺#includeclassBasepublic:virtualvoidf(floatx){cout<<"Base::f(float)஻«x«endl;}voidg(floatx){cout<<"Base::g(float)"<8-2-2(a)ᡂᕒᦪḄ12ஹ⌚8-2-2(b)Dbpgdpᢣᔣᙢᙬᢥᳮ9Ḅx6v᪵஺

59voidmain(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)=>8-2-2(b)12ஹ⌚8-2-3?@D®pd->f(10)Ḅ°/±²ᵨᦪBase::f(int),Base::f(int)´+Derived::f(char*)◚-஺ᵫzᦪ)10µ+◚¶ᙢ·ᓄ¹)º»ᡠ½ᙠ¿À┯஺classBase(public:voidf(intx);ÂbclassDerived:publicBase(public:voidf(char*str);ÂbvoidTest(void)(Derived*pd=newDerived;pd->f(10);//error)=>8-2-3ᵫz◚-PÅÆ┯Ç

60È=>8-2-3Éᩭ◚tᑣËÌmÍ≶஺◚-ᑣϪᨵÐÑÒᙠḄᳮᵫ♦ᑏ®pd->f(10)ḄµÔḄ±²ᵨDerived::f(char*)ᦪÕÖÇ*ᦪᑏ┯஺ᨵ◚-ᑣ¿ÀᘤؽÙÚᢣ┯ÇvÛÜÝx஺ᔲᑣ¿Àᘤß☟ោោᙢ*┯Ø┯?@ᕒ*mâãvÑ┯ÇäἪ᪷஺♦Ꮇ᝞DerivedᨵnÑ(n1èé)ᨵêëìíîïðᦪf஺᝞:ᨵ◚-ᑣñòpd->f(10)µß²ᵨÑÌ/ᧇḄᦪf஺ôõ◚-ᑣÉ©ᩭöòᨵ⍝ᳮøḄÚµùúvî/᜜஺=>8-2-3D᝞®pd->f(10)ï⌕²ᵨᦪBase::f(int),ñò*Derivedýᦋ¹᝞ᓽ஺classDerived:publicBase(public:voidf(char*str);voidf(intx){Base::f(x);})8.3ᦪḄ"ḕ$ᨵ&'ᦪḄ$ᙠ)*+ᦪ,ᵨ./0123ᑏ5᪵Ḅ789:;<=஺C++7@AᵨᦪḄ"ḕ$:3ᑏBCDE(ᙠFG.2"ḕ$ᵫFGᘤJKLᐭ)஺ᦪ"ḕ$Ḅ:ᵨNᑣP•ூNᑣ8-3-1ᦪ"ḕ$STUVᙠ+ᦪḄWXY2Z[TUVᙠ\]^Y஺_᝞PvoidFoo(intx=0,inty=0);//gh2"ḕ$UVᙠ+ᦪḄWXYvoidFoo(intx=0,inty=0)//┯j2"ḕ$UVᙠ+ᦪḄ\]^Y)klm95᪵nᡃpqᨵrstuP&q+ᦪḄvV(\])wᩭyzᦪqᔲᨵ"ḕ$|ᐵ2ᡠᨵ⌕"ḕ$UVᙠ+ᦪḄ\]^Y஺qᦪḄ"ḕ$T9ᦋK2ᯠᦋ+ᦪḄWXᦋ+ᦪḄ\]⌕஺•ூNᑣ8-3-2᝞+ᦪᨵsᦪ2ᦪSTᔣᢸs"ḕ2ᔲᑣ+ᦪ,ᵨ78᪵஺ghḄ_᝞PvoidFoo(intx,inty=0,intz=0);

61┯jḄ_᝞PvoidFoo(intx=0,inty,intz=0);⌕2:ᵨᦪḄ"ḕ$ᨵ+ᦪ¡Ḅ¢T2££q:3ᑏBCDE&'஺¤T9¥¦+ᦪḄ᧕ᵨឋ2©qªT9«¬+ᦪḄᳮ®ឋ஺ᡠᡃ¯ST〉±ᙢ:ᵨᦪḄ"ḕ$2⌕■´:ᵨ[±µ¶·☢ᦔ஺_8-3-2Y2[ᔠᳮᙢ:ᵨᦪḄ"ḕ$¿À+ᦪoutputµ¶]ឋ஺#includevoidoutput(intx);voidoutput(intx,floaty=0.0);voidoutput(intx)(cout<<"outputint஻<

62Complexoperator+(constComplex&a,constComplex&b);ÌÍÎzÛÜ+ᦪᙠ,ᵨ.Ḅ[1ÝᜐqPßàÛÜ+ᦪ2ᦪUVᙠᙊâãᑁZßàÌÍÎ2ᦪUVᙠᐸæஹèé஺_᝞Complexa,b,c;c=Add(a,b);//ᵨÛÜ+ᦪc=a+b;//ᵨÌÍÎ+᝞ÌÍÎê¿Àkᐰì+ᦪ2ímSᨵ&sᦪḄÌÍÎÖ×&ᐗÌÍÎ2ᨵrsᦪḄÌÍÎÖ×ᐗÌÍÎ஺᝞ÌÍÎê¿ÀkïḄᡂᕒ+ᦪ2ím&ᐗÌÍÎᨵᦪ2ᐗÌÍÎSᨵ&sèéᦪ2ukßòJóᡂôæéᦪ஺7õÔö2ÌÍÎ÷\]kᐰì+ᦪ2ª\]kᡂᕒ+ᦪ஺ᦻùúMurray,p44-p47þßÿ⚪Ḅ▊⊤8-4TḄᑣ஺ᑣᡠᨵḄᐗᡂᕒ#ᦪ=0%->()ᡂᕒ#ᦪ+=-=/-*=&/1=ஹ/%=>>=<<=ᡂᕒ#ᦪᡠᨵᐸ4ᐰ6#ᦪ⊤8-4-1Ḅᑣᵫ8C++:;<ᢝ#ᦪ>)?@ᡂ#ᦪᩭᵨC:;CDE஺ᡃG⌕IJKLᩭMNO(1)D⌕SᑖULVWDXᵨ4ḄYZ[ᯠ]^_ᕒG`៉Ḅ#ᦪ஺(2)D⌕SᑖcLᙢeᵨ᝞g4D)ehṹjklm᧕o᧕ᑏqCrᵨᔲᑣXVtuv஺8.4.2D)wḄᙠC++yᔠ{ᨵ|]Dᐕ~wḄ஺▲ᑴ]8ᐰ☢Ḅὃ⇋■┯஺(1)D)ᦋjC++ᑁᦪ(᝞int,float)Ḅ஺(2)D)ᙠ{M¡¢ᡂᕒ£ᨵ¤¥¦§ᡂ᪗©ᵨª஺(3)D)¬C++yᔠ{®ᨵḄ¯᝞#,@,$஺³ᨵ´µ]¶Iᳮ¸/]¶I¹º»ᐜ½஺(4)M¦§¾ᙠḄ¿EÀD)ᦋj»ᐜ½ᑣᔲᑣ?ÁÂ஺8.5#ᦪᑁὶ8.5.1ᵨᑁὶÄhÅhṹ

63C++:;<ᢝ#ᦪᑁὶᐸ¬Ḅ]ÆÇ#ᦪḄ᡻Eᦔ᳛(ËÌ).ᙠC^_{IᵨÅhṹÆÇ᡻Eᦔ᳛஺ÅhṹYÎD]#ᦪÏeᵨÂᩭÐ#ᦪ஺⚜ᜐᳮᘤᵨÔᑴÅhṹḄÕhÖ#ᦪ×ᵨḕÙÚᦪÛ᪘ஹÝᡂÞß:;ḄCALL×ᵨஹâãÚᦪஹ᡻EreturnS^çèÆÇËÌ஺eᵨÅhṹᨬᜧḄëµ]ì᧕┯⚜ᜐᳮᘤᙠÔᑴÅhṹÀKKíݤîDᑮḄð▭ᦔò஺ó᝞tfdefineMAX(a,b)(a)>(b)?(a):(b):úresult=MAX(i,j)+2;?w⚜ᜐᳮᘤ¸þresult=(i)>(j)?(i):(j)+2;ᵫ8'+'''ḄᐜᡠḄresult=((i)>(j)?(i):(j))+2;᝞,-./ṹᦋᑏ3^defineMAX(a,b)((a)>(b)?(a):(b))ᑣ?@AᵫᐜCDḄ┯F஺HIᓽKKᵨMᦋNḄ./ṹOIPQRᜫḄT᝞result=MAX(i++,j);UV⚜ᜐᳮᘤ@[3result=(i++)>(j)?(i++):(j);\C++^_Kᵨ./ṹ`ᨵbRcdeQfghiḄjᨵᦪlᡂᕒ஺oᡃqrrC++Ḅ“tᦪᑁὶ”I᝞xyhḄ஺\zxᑁὶtᦪ{|ᘤᙠ~⊤ᐭtᦪḄ(ᒹஹᦪiஹi)஺᝞,{|ᘤᨵᑁὶtᦪᙠ┯FtᦪḄ/ṹOVᐭ~⊤஺ᙠᵨRᑁὶtᦪ{|ᘤ✌ᐜᵨIᔲ(i¡ᐰᡈὅ¥¦i§ᣚ©ᯠ\ᡠᨵḄtᦪ«R᪵)஺᝞,ᑁὶtᦪḄ/ṹ®¯°±ᣚtᦪᵨIḕ³´tᦪᵨḄµ├஺·¸¹º⚜ᜐᳮᨵ»℉Ḅ½¾3⚜ᜐᳮᘤ¿i¡ᐰᡈὅ¥¦i§ᣚ஺Ꮇ᝞ᑁὶtᦪIᡂᕒtᦪ\ÁḄᙢᙬ(this)®Vᙠᔠ〉ḄᙢÇ·OI⚜ᜐᳮᘤÈᑮḄ஺C++_ḄtᦪᑁὶÊᑴÌᐹᜓ./ṹḄᦔ᳛ÑÒÓ´¡ᐰឋ^Õ?¥ᵫghiḄᦪlᡂᕒ஺ᡠᙠC++¹Ö×ØᵨᑁὶtᦪÙ/ᡠᨵ./ṹ“Ú_assert”អ᝿IÝRḄT᜜஺assertIßᙠDebug᱐ãDhᵨḄ.äᵨ“Ø”åḄæç஺3´ᙠ¹ÖḄDebug᱐ãèRelease᱐ãCDêëassertØìåzxíhᵨ஺᝞,assertItᦪᵫtᦪᵨ®CDᑁஹ/ṹḄî¦UïðDebug᱐ãºRelease᱐ãᙠêñ஺ᡠassertItᦪ^I.஺(ò6.5⁚“KᵨÚ_”)8.5.2ᑁὶᦪḄ{=>ᐵøinlineùúºtᦪûüýᙠRDþ¿Ktᦪᡂ3ᑁὶßUinlineᙠtᦪÿ☢ᵨ஺᝞ḄᦪFooᡂᑁὶᦪinlinevoidFoo(intx,inty);//inline&'ᦪ()*ᙠ,

64voidFoo(intx,inty))-᝞ḄᦪFooᑣᡂᑁὶᦪvoidFoo(intx,inty);inlinevoidFoo(intx,inty)//iniine'ᦪ/01*ᙠ,()ᡠ345inline6,7“ᵨ9:;Ḅᐵ=>”5-6,7“ᵨ9()Ḅᐵ=>”஺-,Aᙢ5ᵨᡝD3▅FᦪḄ()5G6HᑮᦪḄ/0஺JKᙠᜧMᦪᦟOPQᑁὶᦪḄ()ஹ/01S☢TUVinlineᐵ=>5GᡃXinlineYZ[;ᙠᦪḄ()Q஺\]^⁚`ᯠbcdᦪḄe5G61;VfghC++/CklmnḄ,]opqᑣ()'/0Dr,s5ᵨᡝtᨵv⌕ஹxYZy⍝ᦪ6ᔲ◤⌕ᑁὶ஺/0ᙠ}()~QḄᡂᕒᦪᙢᡂᑁὶᦪ5᝞classA(public:voidFoo(intx,inty){…}//ᙢᡂᑁὶᦪ)ᡂᕒᦪḄ/01*ᙠ}()~Q`ᯠᩭPᑏḄ5G6,7Ḅk5YZᦋᡂ//ᜮᦻclassA(public:voidFoo(intx,inty))///0ᦻiniinevoidA::Foo(intx,inty)(}8.5.3¡ᵨᑁὶᑁὶ¢fᦪḄ᡻¤ᦔ᳛5§¨©ᡠᨵḄᦪT/0ᡂᑁὶᦪª᝞«ᡠᨵḄᦪT6ᑁὶᦪ5¬ᵨḼ“ᑁὶ”\]ᐵ=>ᔩªᑁὶ63°ṹ²³(´ᑴ)°¶5&&ḕ¸Vᦪ¹ᵨḄº├5¼-¢fᦪḄ

65᡻¤ᦔ᳛஺᝞«᡻¤ᦪ1ᑁ°ṹḄ½¾5¿À9ᦪ¹ᵨḄº├Áᜧ5¨ᦔ᳛ḄᦈÄbÅÆ஺Ç,☢5È,ᜐᑁὶᦪḄ¹ᵨT⌕´ᑴ°ṹ5ÊklḄË°ṹhÌᜧ,ÍὑÏMḄᑁÐѾ஺3ÒÓÔÊᵨᑁὶ(1)᝞«ᦪ1ᑁḄ°ṹÀÁÕ5ÊᵨᑁὶÖ×ᑁÐÍὑ°¶Áf஺(2)᝞«ᦪ1ᑁ[;ØÙ5¨᡻¤ᦪ1ᑁ°ṹḄ½¾⌕Àᦪ¹ᵨḄº├ᜧ஺}Ḅ᪀⌼ᦪÜ᪆᪀ᦪÞ᧕àáâãᡂÊᵨᑁὶÏᨵᦔ஺⌕äå᪀⌼ᦪÜ᪆᪀ᦪDb◚ç,è¤5᝞“ᏕᏕᙢ”᡻¤Vo}ᡈᡂᕒëìḄ᪀⌼ᦪÜ᪆᪀ᦪ஺ᡠ3⌕íᙢ᪀⌼ᦪÜ᪆᪀ᦪḄ/01*ᙠ}()Q஺,]Ḅîᘤb᪷ñᦪḄ/015ᙢòÍóḄᑁὶ(\ô,õ4)TinlineYZ[;ᙠᦪḄ()Q)஺8.6,èå1bC++ö÷QḄøùஹᑁὶஹúḕûᦪஹ◚üýᣚÿᑴḄ◚Ḽ◚஺᝞Ḅ!"#$%ាᑮ(ᜐ஺ᡃ⌕,-ᙢ/0C++Ḅ1ᑴ$2ា᝞ᐸᑖᙢ5ᵨ7஺8ᯠ:5ᡃ;<=>?@ABC;<ḄDE஺

66G9HIḄ᪀⌼Lᦪஹ᪆᪀LᦪPQRLᦪ᪀⌼Lᦪஹ᪆᪀LᦪPQRLᦪSTIᨬVᩈḄLᦪ஺7XYZ[\]^᧕`aᜧcᐸdefgᓫḄLᦪijkᨵ⚔nḄop⍝r᪵ᓻ◅஺STIvᨵT᪆᪀LᦪTQRLᦪ"[ᨵT᪀⌼Lᦪ(ᒹyTz{᪀⌼Lᦪᐸ7Ḅ|}YZ᪀⌼Lᦪ)஺cTIA,᝞!;ᑏLᦪC++;ᘤ}ATḕḄLᦪ᝞A(void);஻ḕḄᦪ᪀⌼LᦪA(constA&a);஻ḕḄz{᪀⌼Lᦪ~A(void);஻ḕḄ᪆᪀LᦪA&operate=(constA&a);//ḕḄQRLᦪ!Ἥ]ᶧ«¬ᯠᡂLᦪ}¯°±⌕<²ᕒ;ᑏ´µ¶᝞o·(1)᝞5ᵨ“ḕḄᦪ᪀⌼Lᦪ”“ḕḄ᪆᪀Lᦪ”»¼½¾“¿Àᓄ”“Â◀”Ḅ:C++ÄÅStroustrupḄ(?(cÈ>஺(2)“ḕḄz{᪀⌼Lᦪ”“ḕḄQRLᦪ”ᙳËᵨ“Ìz{”ÍΓRz{”ḄÏÐᩭd᎚ÓIÔyᨵᢣ┐×ØÙTLᦪÚÛÜ┯஺rkᨵᔛßàᜮḄC++<²ᕒ᝞âã;ᑏ᪀⌼Lᦪஹ᪆᪀LᦪPQRLᦪ^᧕"[!ᵨᾯå⊤ÅâḄçè±éêëìpíᨵ0îï஺ðH[IStringḄòóPd}ôõᐭ▊øᦟúûüýḄ⍝ᳮ஺StringḄÿ᪀᝞classStringpublic:String(constchar*str=NULL);//᪀⌼!ᦪString(constString&other);//%&᪀⌼!ᦪ~String(void);//᪆᪀!ᦪString&operate=(constStringftother);//,-!ᦪprivate:char*mdata;//ᵨ012345)69.1᪀⌼!ᦪ7᪆᪀!ᦪḄ9:;<=C?ᐜAḄBCDC++FGH?IḄJᑴᩭMNOPḄQᐰឋ஺C++UVᘤᐹᨵZ[Ḅ\]Qᐰ^_`aDbcdaefOPgᡠᨵḄBij⚪DlḄmnrOP

67ᕒḄᜧq஺rsOPtHUV^_uv⊤x┯z{|v2ᙠHDᙠ“┯z”ḄᜧD“Bi┯z”Ḅᙢas஺Ḅ┯z◚DḄDv᧕஺᪷|¡Dv¢£¤¥¦ḄOP┯zsᵫ0¨©ªᨵ«¬m®ᓄᡈ±◀⌼ᡂḄD´®ᓄµ±◀¶;᧕«·⍡¹஺Stroustrupᙠº»C++BC¼ᐙᑖὃ⇋HlÁj⚪uIᙢ¤ÃÄÅÆḄ®ᓄ¶;Çᙠ᪀⌼!ᦪgDű◀¶;Çᙠ᪆᪀!ᦪg஺ÈÆ«ÉʼD᪀⌼!ᦪ«ËÌ᡻Î஺ÈÆÏмD᪆᪀!ᦪ«ËÌ᡻Î஺lvᵨÑÒ¹HÆḄ®ᓄµ±◀¶;஺᪀⌼!ᦪ7᪆᪀!ᦪḄÓ3vaÔÕ9DÖ×ØUVᘤÙfÚ¤«ËÌ᡻Î஺StroustrupḄÛÓÜiÝÞᓫàᔠᳮØ᪀⌼!ᦪஹ᪆᪀!ᦪ7\äÓDᵫ0᪆᪀!ᦪḄåḄ7᪀⌼!ᦪḄæçDèéê¤xë஺◀HÓ3᜜D᪀⌼!ᦪ7᪆᪀!ᦪḄíîÁᱯðᜐsªᨵòó-\]Dl7òó-\]ᓾᙠ(ᦪA(}=C஺DEFG⊤HḄ+,ᓄIJKᙠ(ᦪAᑁḄMNOṹQ᡻S=C஺᪀⌼(ᦪ+,ᓄ⊤ḄTᵨᑣW♦᝞YZᙠ[\ᐵ^_`aᙠᐸ+,ᓄ⊤HcᵨdḄ᪀⌼(ᦪ஺e᝞classA{...A(intx);//AḄ᪀⌼(ᦪ)hclassB:publicA{...B(intx,inty);//BḄ᪀⌼(ᦪ)hB::B(intx,inty):A(x)//ᙠ+,ᓄ⊤HcᵨAḄ᪀⌼(ᦪ)♦Ḅconstklmnᙠ+,ᓄ⊤HQ+,ᓄopnᙠ(ᦪAᑁᵨqḄ23ᩭ+,ᓄ("s5.4⁚)஺

68♦ḄᦪtᡂᕒḄ+,ᓄwxᵨ+,ᓄ⊤ᡈ(ᦪAᑁqz{23Dz{23Ḅᦔ᳛~ᐰ஺|ᑁ}ᦪ~#nḄᡂᕒ`ᵨᓄYḄᦔ᳛஺s᝞classA{...A(void);//"ᦪ᪀⌼(ᦪA(constAMother);//᪀⌼(ᦪA&operate=(constAftother);//q(ᦪ};classB(public:B(constA&a);//BḄ᪀⌼(ᦪprivate:Am_a;//ᡂᕒ}h¡e9-2¥)¦BḄ᪀⌼(ᦪᙠᐸ+,ᓄ⊤HcᵨAḄ᪀⌼(ᦪ§¨ᡂᕒm_a+,ᓄ஺¡e9-2(b)¦BḄ᪀⌼(ᦪᙠ(ᦪAᑁᵨqḄ23ᡂᕒm_a+,ᓄ஺ᡃª«ᑮḄm®ᩩq°±¥²▭BḄ᪀⌼(ᦪz´µWᐜᨩᙢH¹ºka(cᵨAḄ"ᦪ᪀⌼(ᦪ)¼cᵨAḄq(ᦪ"ᦪaq½B::B(constA&a)B::B(constA&a):m_a(a)((m_a=a;))¡e9-2(a)ᡂᕒᙠ+,ᓄ⊤¦Q+,ᓄ¡e9-2(b)ᡂᕒᙠ(ᦪAᑁQ+,ᓄ<ᑁ¾ᦪtḄᦪtᡂᕒ¨¿z{+,ᓄ23Ḅᦔ᳛ÀÁᨵÂÃ¥>ὅḄÅÆ᱐3ÈÁÉÊᨎÌ஺ÍFḄÏF᝞ÐWclassF(public:F(intx,inty);//᪀⌼(ᦪprivate:intm_x,m_y;intm_i,m_j;

69)¡e9-2(c)¦FḄ᪀⌼(ᦪxᵨÕ®{+,ᓄ23¡e9-2(d)¦FḄ᪀⌼(ᦪxᵨÕÖ{+,ᓄ23஺F::F(intx,inty)F::F(intx,inty):m_x(x),m_y(y)((m_x=x;m_i=0;m_yÖy;m_j=0;m_i=0;)m_j=0;}¡e9-2(c)ᦪtᡂᕒᙠ+,ᓄ⊤¦Q+,ᓄ¡e9-2(d)ᦪtᡂᕒᙠ(ᦪAᑁQ+,ᓄ9.3᪀⌼Ø᪆᪀ḄÚÆ᪀⌼§ÛÚḄᨬ᪷ᜐß,ᙠà®Û¦✌ᐜcᵨdḄ᪀⌼(ᦪᯠ>cᵨᡂᕒḄ᪀⌼(ᦪ஺᪆᪀ᑣãäᢥ᯿ç᪀⌼èḄÚÆ᡻SGÚÆé®Ḅᔲᑣᘤëìí᡻S᪆᪀îÅ஺®/ᨵïḄðᡂᕒ+,ᓄḄÚÆ~ᐰñpªᙠ+,ᓄ⊤¦ÚÆḄòómᵫᡂᕒᙠ¦ÏFḄÚÆõ஺DoḄÏFé®Ḅ¨Ḅ᪀⌼(ᦪwᨵö/o÷øᨵö/ÚÆḄ+,ᓄ⊤஺᝞Yᡂᕒᢥ᯿+,ᓄ⊤ḄÚÆùS᪀⌼,Dúû᪆᪀(ᦪëüᑮé®Ḅ⌮Æ஺[Eckel,p260-261]9.4StringḄ᪀⌼ᦪ᪆᪀ᦪ//StringḄ᪀⌼ᦪString::String(constchar*str)(if(str==NULL)(mdata=newchar[1];*m_data=4\0';)elseintlength=strlen(str);m_data=newchar[length+1];strcpy(m_data,str);

70}//StringḄ᪆᪀ᦪString::"String(void)Jdelete[]m_data;//ᵫ>m_data?ᑁAᦪBC4DEFᑏᡂdeletem_data;9.5I⌕KLMN᪀⌼ᦪOPᦪᵫ>QRᡠᨵḄUVWXYᵨMN᪀⌼ᦪ[OPᦪ4\]ᕒE_U`abᦪᨵcKL஺eᐜghFiḄjk4ᙠ▅noᦻqrXst♦uvwᜮyz4᝞|I}~ᑏMN᪀⌼ᦪ[OPᦪ4ᘤF“MN”Ḅ~ᡂḕḄᦪ஺᎚ᨵᢣ┐4`abḕḄᦪr◚┯஺FStringḄabUVa,b4Ꮇa.mdataḄᑁ“hello”4b.m_dataḄᑁ"world"஺aO¡b,ḕOPᦪḄ“MN”¢ᕡḼ᡻¦b.m_data=a.m_data஺`⌼ᡂ§b┯¨?b.mdata©ᨵḄᑁª«¬®4⌼ᡂᑁª¯☄±²?b.m_data[a.m_dataᢣᔣ´•ᙽᑁª4aᡈb¸¹¨~WXº»¼¨±§?ᙠUV¬᪆᪀q4m_data¬®a½஺♦MN᪀⌼ᦪ[OPᦪR¾᧕ÀÁ4¾ÂÃ┯ᑏஹ┯ᵨ஺MN᪀⌼ᦪ?ᙠUV¬ÅÆqÇᵨḄ4ÈOPᦪÉ_¬Ê˪ᙠḄUVÇᵨ஺Fi\]4̧bÍÎ[ÌÏbÍÎÐÑÒ4ÓᑖÕÖ×ØbÇᵨMN᪀⌼ᦪ4ÙBbÇᵨOPᦪᔩÜStringa("hello");Stringb("world");Stringc=a;஻ÇᵨMN᪀⌼ᦪ4ᨬßᑏᡂc(a);c=b;஻ÇᵨOPᦪu̧bÍÎḄàáâã4äᦋᑏᡂStringc(a)Fæç>ÌÏbÍÎ஺9.6StringḄMN᪀⌼ᦪOPᦪ//MN᪀⌼ᦪString::String(constString&other)

71//ᐕêëìotherḄíᨵᡂᕒm_dataintlength=strlen(other,mdata);m_data=newchar[length+1];strcpy(mdata,other,mdata);)//OPᦪString&String::operate=(constString&other)(//(1)îïOPif(this==&other)return*this;//(2)®©ᨵḄᑁªñòdeleteómdata;//(3)ᑖõöḄᑁªñò4Q÷ᑴᑁintlength=strlen(other,mdata);mdata=newchar[length+11;strcpy(m_data,other.m_data);//(4)úûuUVḄüᵨreturn*this;)StringMN᪀⌼ᦪ᪀⌼ᦪ(ýþ9.4⁚)Ḅᙠᦪᐭᜐ◤NULL“ᵨ”!"#NULL,%“ᢣ┐”"(NULL஺*StringḄ12ᦪ᪀⌼ᦪ5ᩖ78ᑖ:;<=(1)@A;BCD12஺E"#FG8HAIJ⍝ᨵMFN≶ᑮᑏRa=a᪵ḄD12WXYḄZ!F஺[\]ḄD12^ᨵ"#R=_᝞//ᑁcD12//ᙢᙬD12b=a;b=&a;c=b;aj*b;a=c;lmᨵMFn“ᓽpR=D12ᡃl"(!ᳮsᜧ!uᓄwx\yz{5ᑴD}%~!FR┯Y”

72Ḅn┯u஺@j;Ḅdelete,Dᩔ#5ᑴD}ᔩᡠ(᝞=D12ᦪ஺!⌕BCD12ḄifWXif(this==&other)┯ᑏᡂif(*this==other)(2)@j;ᵨdelete¡¢ᨵḄᑁ£¤¥஺᝞=ᙠ!¡(¦§¨Fu⌼ᡂᑁ£©☄஺(3)@¬;ᑖ®Ḅᑁ£¤¥¯5ᑴ°±²஺ᦪstrlen³´Ḅᨵᦔ°±²¶·!ᒹ¹º»±'\0'஺ᦪstrcpyᑣÂ(\0,AÃ5ᑴ஺(4)@:;³´Äz{ḄᵨÅḄu<={a=b=c᪵ḄÆÇ⊤É஺!⌕return*this┯ᑏᡂreturnthis஺ËÌ#ᔲᑏᡂreturnotherᕖᦔ!A᪵ᔩ!"(YᡃÏ!Ð⍝ÑᦪotherḄÒÓÔ஺ᨵ"#otherÕÖxz{ᙠ12º»×ØᜫËÌreturn0ther³´ḄᚗÛ஺9.7ᏕÝḄÞßᜐᳮàá᪀⌼ᦪ12ᦪ᝞ᡃÏ<ᙠ!âãᑏàá᪀⌼ᦪä12ᦪå!ᐕmMpᵨãçᘤÒᡂḄéḕᦪëÌÞᏕÝḄÞßì◤àá᪀⌼ᦪä12ᦪíîïᨵᦪ!ᵨãᑏðṹ஺_᝞classA{...private:A(constA&a);//ïᨵḄàá᪀⌼ᦪA&operate=(constA&a);//ïᨵḄ12ᦪ)ö᝞ᨵM÷øãᑏ᝞ùúûAb(a);஻ýᵨuïᨵḄàá᪀⌼ᦪb=a;//ýᵨuïᨵḄ12ᦪãçᘤᢣR┯þ᜜AḄᨵᦪ஺9.8᝞ᙠḄᦪḄ᪀⌼ᦪஹ᪆᪀ᦪஹᦪ!"#஺᝞$%&'ᙠ"#ᐵ)*ᙠ+ᑏ-.ᦪ/01234⚗6♦Ḅ᪀⌼ᦪ0ᙠᐸ89ᓄ⊤<=ᵨḄ᪀⌼ᦪ஺

73♦?Ḅ᪆᪀ᦪ0@AB(ᓽEvirtualᐵMN)஺P᝞#includeclassBase(public:virtual'Base(){cout<<"dBase”<

74Derived&operate=(constDerived&other);//DerivedḄᦪprivate:intm_x,m_y,m_z;)hDerived&Derived::operate=(constDerivedMother)(//(1)if(this==&other)return*this;//(2)xḄᦪyᡂᕒ|}Base::operate=(other);//Aᨵᦪyᡂᕒ//(3)xḄᦪyᡂᕒm_x=other.m_x;m_y=other.m_y;m_z=other.m_z;//(4)xḄᵨreturn*this;)9.9ᨵC++¡¢£¤᪀⌼ᦪஹ᪆᪀ᦪ¥ᦪ¦Ḅ“Big-Three”*ª«Ḅ¬¦ᨬ|⌕Ḅᦪ*¯°±஺²³´µA¶Ḅᑁ¯¸¹º»¼*½¼¾¿ÀÁ4*ᡃÃÄÅÆ஺᝞$´ÇÈᔛÊ“Big-Three”*ËÌÌ▅ÎÏὃᦻÒ[Cline][Meyers][Murry]஺

75Õ10¶Ḅ"#?Öᔠx(Object)¦(Class)ḄÄP(Instance)«᝞$ØxÙÚÛ,st¾¦ÚÛḄ¡ÜÝ஺ᡠ☢ᔣx¡Ḅ|á¦Ḅ¡*â¦xḄ¡஺xãC++âä*¡åæḄ¦Ùç¯᧕Ḅ*éḄ¦ê¬¡ëᐸ஺¶ììí.“"#”(Inheritance)¥“Öᔠ”(Composition)Ḅᭆï஺12*ðñ☢ᔣxᢈóḄ0ᵨôá¦COM¥CORBA,Ãᑁ¯õp¼C++ᦟᩞḄᶖ*Ë▅ÎCOM¥CORBAúᐵí℉஺10.1"#᝞$A¦*B¦AḄ*stBØ"#AḄᦪy¥ᦪ஺P᝞6classA(public:voidFuncI(void);voidFunc2(void);)

76./ᵨ0ᑣ஺•ூ0ᑣ10-1-12᝞56A76B89:ᐵ!9/BḄ<=>?.@ABAḄ<=7Bឋ஺9⌕CD“EᔛE9ᔛ”!AGHHḄᏉJ☘LMNMᦑᙢᔛQR⊡TU஺•ூ0V!|10-1-22Yᙠ[\]B^AḄ“_"aakindof,ᑣᐕcBAḄ<=7Bឋ஺᝞ᵱQaMan^QaHumanḄ_!ᵱeaBoy^ᵱQḄ-_஺gh6Mani6Humanjk!6Boyi6Manjk஺classHumanclassMan:publicHumanclassBoy:publicMan♦lm⚗ூ0ᑣ10-1-22opᩭrsᓫ!u^▭)ᵨw=xᨵm᜜!Ḅᭆ{ᙠ|}~|}9ᐰ:஺᝞ikᱥ!aOstrich^BirdḄ_!ᢥᳮ6Ostrich)i6Birdjk஺u^9=!ghOstrich::Fly^hclassBirdpublic:virtualvoidFly(void);classOstrich:publicBird᝞iᦪ!ᙊaCircle^_ᱯḄᙊaEllipse,ᢥᳮ6Circle)i6Ellipsejk஺u^ᙊᨵ7!᝞5ᙊᙊḄᑭ!

77ᡠ>¢£¤Ḅ0ᑣ)*^Yᙠ[\]B^AḄ“_”!¥AḄᡠᨵ<=7Bឋ¦B@§¨ᨵm©!ᑣᐕcBAḄ<=7Bឋ஺10.2ªᔠ•ூ0ᑣ1021௃Yᙠ[\]A^BḄ“ᑖ”(apartof),ᑣ9ᐕcBiAjk!@^⌕ᵨA7ᐸ±ªᔠ²Bo᝞³(Eye)ஹ´(Nose)ஹU(Mouth),ὡ(Ear)^ᜮ(Head)Ḅᑖ!ᡠ6Head)ᵫ6EyeஹNoseஹMouthஹEarªᔠ@ᡂ!9^jk@ᡂ஺᝞¹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ªᔠ@ᡂ᝞5ᐕcHeadiEyeஹNoseஹMouth>Earjk@ᡂ!ghHeadÄÅÆᐹᨵLookஹ

78SmellஹEatஹListenÈ.<=஺¹10-2-2ᓝᑖs¥Ê˼!u^È_½¾ÌÍᓾ^9¦Ḅ஺//<=¼¥ÁṹsÏ!u^½¾ÌÍ9¦஺classHead:publicEye,publicNose,publicMouth,publicEar(к_____________________________________________________________________________¹10-2-2HeadiEyeஹNoseஹMouthஹEarjk@ᡂÒÓÔ/ÕᙢÖᡭÒØÙÚḄÛÔ!ÜÝ⍝hᔩÛÔÙàÚ஺r?ᕒâ9p“”Ḅãä@åÙ½¾┯ç஺“Ê˼”Ḅ9èD^éêḄ!ëᜐí^î஺

79ïUðᐸ±ñâò11.1/ᵨconstóᦪḄᏉJឋoᑮconstᐵõö!C++ᕒ✌ᐜùᑮḄ=^constúê஺È9^ûGḄᩩýþÿ஺᝞⍝ᵨconstᵨᑴ஺constᜧḄ!"⛲$ᦪḄ&ᦪஹ()*+,$ᦪḄ-஺constconstantḄ.ᑏ“ឤ23”Ḅ56஺7const"⛲Ḅ89:;ᑮ=ᑴ>?,!⚜■5᜜Ḅ3DEFGHIḄᏉKឋ஺ᡠ!NOC++HIPQRSTU:“Useconstwheneveryouneed”஺11.1.1ᵨconst⛲ᦪḄcᦪ᝞&ᦪWXᵨ2YZᦪ[\]^2Y_ᵨ“ᢣ┐b⌴”d“eᵨb⌴”:2Efconst"⛲ᔲᑣi&ᦪjᜫlWXmE஺constE"⛲Wᐭ&ᦪo♦᝞Wᐭ&ᦪ_ᵨ“ᢣ┐b⌴”fconst"⛲!■q5᜜ᙢᦋDiᢣ┐tᑮ>?ᵨ஺u᝞StringCopy$ᦪovoidStringCopy(char*strDestination,constchar*strSource);ᐸwstrSourceWᐭ&ᦪstrDestinationWX&ᦪ஺xstrSourcefyconst"⛲z᝞$ᦪ-ᑁḄ|}~ᦋDstrSourceḄᑁᘤjᢣX┯஺♦᝞Wᐭ&ᦪ_ᵨ“*b⌴”ᵫ$ᦪjD3ᵨᑴi&ᦪiWᐭ&ᦪᩭ◤>?ᡠ!2⌕fconst"⛲஺u᝞2⌕j$ᦪvoidFund(intx)ᑏᡂvoidFund(constintx)஺ᳮ2⌕j$ᦪvoidFunc2(Aa)ᑏᡂvoidFunc2(constAa)஺ᐸwAᵨᡝḄᦪ[\]஺♦ᑁᦪ[\]Ḅ&ᦪvoidFunc(Aa)᪵¡Ḅ$ᦪ¢ᦔ᳛¥¦§஺¨$ᦪ-ᑁjA\]Ḅᵨᑴ&ᦪa,Ḅ᪀⌼ஹᑴஹ᪆᪀¬H:jὑ¯஺°FGᦔ᳛!j$ᦪ¡ᦋvoidFunc(A&a),¨“eᵨb⌴”±ᵨ²³&ᦪḄ´µ¶2◤⌕஺·$ᦪvoidFunc(A&a)¸ᙠ•»¼½o“eᵨb⌴”ᨵEᦋ3&ᦪa,ᡃÀ2ÁÂḄ஺ÃÄ»Å⚪N᧕fconst"⛲ᓽ¨É$ᦪᨬËᡂvoidFunc(constA&a)஺!É\ÌᔲÍjvoidFunc(intx)ᦋᑏvoidEunc(constint&x),!ÎFGᦔ᳛ÏÐᐰÒᨵÓ⌕¨ᑁᦪ[\]Ḅ&ᦪ2¸ᙠ᪀⌼ஹ᪆᪀Ḅ¬Hᑴ^Ô''*b⌴”Ö“eᵨb⌴”Ḅᦔ᳛×Ø஺Å⚪᝞ÉḄÙÚᡃÛj“const&”"⛲Wᐭ&ᦪḄᵨÝÞß²³᝞⊤11-1-1

80ᡠá஺ᑁᦪ[\]ḄWᐭ&ᦪÍij“*b⌴”Ḅâãᦋ“consteᵨb⌴”éḄFGᦔ᳛஺u᝞jvoidFunc(Aa)ᦋvoidFunc(constA&a)஺ᑁᦪ[\]ḄWᐭ&ᦪ2⌕j“*b⌴”Ḅâãᦋ“consteᵨb⌴”஺ᔲᑣóô2ᑮFGᦔ᳛ḄéḄõö÷°$ᦪḄᳮÃឋ஺u᝞voidFunc(intx)2ÍiᦋvoidFunc(constint&x)஺⊤11-1-1"const&”"⛲Wᐭ&ᦪḄüᑣ11.1.2ᵨconst"⛲$ᦪḄ()*♦᝞x!“ᢣ┐b⌴”âãḄ$ᦪ()*fconst"⛲$ᦪ()*(ᓽᢣ┐)Ḅᑁ2E7"ᦋi()*E7ÿconst⛲Ḅᢣ┐஺᝞ᦪconstchar*GetString(void);᝞#$%&'()*┯,-char*str=GetString();/0Ḅᵨ23constchar*str=GetStringO;♦᝞5ᦪ6789ᵨ“8;⌴=>”@ᵫBᦪCD678Eᑴᑮ᜜IJKḄLMᓫᐗP@const⛲QᨵSTU8஺᝞V⌕DᦪintGetlnt(void)ᑏᡂconstintGetlnt(void)0ᳮV⌕DᦪAGetA(void)ᑏᡂconstAGetA(void),ᐸPA`ᵨᡝbcdḄᦪe஺᝞5678V3ᑁIᦪe@&ᦪAGetA(void)ᦋᑏ`constA&GetA(void)Ḅ0ijkᦔ᳛஺noKᓟqᓟq⌕rs@tc⌕uvwᦪxy3z67t{|}Ḅ“~”367“”@ᔲᑣC'┯஺6.2⁚“678Ḅᑣ”஺♦ᦪ6789ᵨ“ᵨ;⌴”ḄᔠV@=>•'(ᙠḄ8ᦪP@Ḅ3`(>⊤¢஺᝞classA(-A&operate=(constA&other);//8ᦪ)¦Aa,b,c;//a,b,c`AḄ|}a=b=c;///¨Ḅ>8

81(a=b)=c;஻V/¨Ḅ>8@nᔠ2᝞5&8ᦪḄ678const⛲@ª«¬678ḄᑁVᐕ¯°ᦋ±஺²P@$%a=b=c³ᯠ/0@n3$%(a=b)=cᑣ3µ2Ḅ஺11.1.3constᡂᕒ>ᦪSTVCᦋᦪeᡂᕒḄᦪ·¸¬¹º`const஺᝞5ᙠ)ᑏconstᡂᕒᦪK@V»ᦋᦪeᡂᕒ@ᡈὅ¾ᵨᐸ¿µconstᡂᕒᦪ@)*ᘤ&ᢣ'┯,@ÁᶧCjkḄᏉÄឋ஺#P@stackḄᡂᕒᦪGetCounlᵨBÉᦪ@ÊË̲ÍGetCount¸Î`constᦪ஺)*ᘤ&ᢣ'GetCountᦪPḄ┯,஺classStack(public:voidPush(intelem);intPop(void);intGetCount(void)const;//constᡂᕒᦪprivate:intm_num;intmdata[100];)¦intStack::GetCount(void)const(++m_num;//)*┯,@×Øᦋᦪeᡂᕒm_numPopO;஻)*┯,@×ؾᵨµconstᦪreturnmnum;)constᡂᕒᦪḄ¹ºÙÚᩭÜÜḄ-constᐵÞßiàᙠᦪ¹ºḄáI@ᜧᭆ3ä`ᐸ¿ᙢ=·æç°ᓰᵨ஺11.2jkḄᦔ᳛ḄKéᦔ᳛3ᢣêëìí@îéᦔ᳛3ᢣᓰᵨᑁLᡈὅ᜜LḄïð஺ᐰòᦔ᳛3ᢣóᙠ᦮{õöḄ÷í²ὃ⇋Ḅᦔ᳛@òIᦔ᳛3ᢣóᙠúᙽᡈᦪ÷í²ὃ⇋Ḅᦔ᳛஺ூAᑣ11-2-1௃V⌕tᕡᙢþÿḄᦔ᳛ᙠឋஹ☠ឋஹᏉឋஹឋḄḄᦔ᳛஺

82ூ"ᑣ11-2-2$Ḅᐰ&ᦔ᳛'(&)ᦔ᳛'*஺•ூ"ᑣ11-2-3௃ᙠ-ᓄḄᦔ᳛/ᐜ12▲ᑴᦔ᳛Ḅ“6⚠”9⌕ᙠ;ᐵ=⌕>ᜐ-ᓄ஺•ூ"ᑣ11-2-4ᐜ-ᓄᦪAB᪀DEF-ᓄ᡻HIṹ஺•ூ"ᑣ11-2-5ᨵ/᎛/Mᦔ᳛DNMᦔ᳛OPQR/ᑖ᪆UVWX⌕Y2〉Ḅᢚ⊭஺]᝞_`abcᑁeᩭឋO஺•ூ"ᑣ11-2-6௃9⌕gh=iḄIṹ'=iḄIṹj9OklᦔḄmᘤṹ஺11.3CDᨵFḄGHoூpq11-3-1௃rUcstu9᧕ᑖwḄxYyzl{ᑏ┯~஺ᡃ“==”~ᑏᡂ“="“II"ஹ“&&”ஹ“<="ஹ">=”y᧕zl“1”ᜫ~஺ᯠᘤᓾ9bOᢣ2┯~஺oூpq11-3-2ᢣ┐ஹᦪ¡¢£p>¤¥/¦§¨ᓄ$■ª«¢§¨ᓄḄᡂ¬®ᵨ஺oூpq11-3-3௃rḄ§ஹ°ḕ┯~ᡈὅ´µ9¶஺oூpq11-3-4rᦪA·¸ᣚzl┯~஺º®ᵨ»¼ḄᦪA·¸ᣚ½¾¿⍝zlÁÂÃÄ¡ÅƽᘤÇោោᙢÊH◚¼ḄᦪA·¸ᣚ஺oூpq11-3-5௃rzluÌᡈÌᦪḄ᪗ÎÏ஺oூpq11-3-6௃rÐÑᑏ┯~ᜐᳮr┯~ᜐᳮÓÔᨵ~஺oூpq11-3-71rᦻÖI/Oᨵ┯~஺oூpq11-3-8ÅÆᑏᢈØឋIṹ஺oூpq11-3-99⌕Ù☢☢ÛᑮஹÝᮣßḄᦪAB᪀஺oூpq11-3-10᝞àáᨵḄIṹâãäºåᵨ¦஺æç9⌕è⊡êëḄIṹXìᑏ஺

83oூpq11-3-11º®ᵨ᪗íîïᦪ9⌕“zð”ñeᙠḄîïᦪ஺oூpq11-3-12º9⌕®ᵨòᐹôõÖᡈöÖ÷᛻ᐵùúᑗḄ஺oூpq11-3-13௃ᘤḄ⌱ý⚗ÿᨬ᝱஺ூ11-3-14᝞ḄᵨPC-LintஹLogiScopeᐹṹ஺

84ὃᦻ"[Cline]MarshallP.ClineandGregA.Lomow,C++FAQs,Addison-Wesley,1995[Eckel]BruceEckel,ThinkinginC++C++#$%&ᑢ(ᵪ*+,-./᱐12000[Maguire]SteveMaguire,WritingCleanCode2#$345☟7*+ᵯ9./᱐11993[Meyers]ScottMeyers,EffectiveC++,Addison-Wesley,1992[Murry]RobertB.Murry,C++StrategiesandTactics,Addison-Wesley,1993[Summit]SteveSummit,CProgrammingFAQs,Addison-Wesley,1996

85▬;A.C++/Cṹ⊤ᦻJ᪀=⌕ឋ⚗ABᜮᦻDEFGᦻDḄHIJᔲᔠᳮNᜮᦻDEFGᦻDḄO;A᪀JᔲᔠᳮN᱐ᩗE᱐RSTJᔲU᦮NK⌕ᜮᦻDJᔲᵨWifndef/define/endif⚜ᜐᳮᙽNᜮᦻD[Jᔲ\]^“ST”ab]^"FG”.......MNḄ᱐#=⌕ឋ⚗ABdJᔲefNṹᑁḄdJᔲefNhiᑖJᔲefN“kE“}”JᔲᔜᓰopqrstuoᑡNK⌕oṹJᔲ\woDxN᝞\FGoyz{\ᑏoᩩ~஺K⌕If\forஹwhile>do~ᓰbB᡻~⌕“{}K⌕ᙠFGz{2ᡈᦪ+Jᔲ⛲*E&☠z{HNJᔲᨎp⌕NK⌕Jᔲᨵ┯ᡈὅNK⌕¡A᪀Ḅpublic,protected,private¢£JᔲᙠᡠᨵḄ$£[¥ᢝoN........OPAᑣ=⌕ឋ⚗ABK⌕§H¨ᑣJᔲªᡠ«ᵨḄ¬®¯ᡈ°±ᐹḄ²¥ᢝoN᪗´Jᔲµ¶q·¸¹N᪗´Ḅhº»¼ᔠ“min-length&&max-informationw½ᑣNK⌕$£[Jᔲ/¾¿uḄÀÁz{EᐰÁz{N¡HஹÃᦪHஹz{EᦪஹÄ{ḄÅᑏÆJᔲ⍳ÈoFḄ¨ᑣN☟᝱z{ஹᐰÀz{ஹ¡Ḅᡂᕒz{JᔲËÌN

86⊤Q#RSTU=⌕ឋ⚗ABK⌕᝞ṹ[ḄÍÎÏÐJᔲÑÒᵨÓÔÕᙢ×F⊤ØÆḄ¬¢£NJᔲ#ᑏÙÚᩖᡈὅᵨ⌶ḄÚᔠ⊤ØÆNK⌕JᔲÚᔠ⊤Øƪ“ÝÞḄᦪß⊤ØÆ”àáNK⌕Jᔲᵨ◚ã┯ḄäÆᑏif~Nå᝞(1)æçz{µèªTRUEஹFALSEᡈὅ1ஹ0ÏÐ஺(2)éêz{ᵨ“=="ᡈ"ì=”ªíîᦪïÏÐ஺(3)ᢣ┐z{ᵨ“=="ᡈ"ì=”ªNULLÏÐ஺᝞Èòfᑁ]ᙠóôᑨöpqÈò÷ᦪøᜧJᔲÑÒóôᑨöúᑮÈòfḄ᜜☢NK⌕Case~ḄAþJᔲÿbreak?K⌕ᔲᑏswitchḄdefaultᑖK⌕ᵨgotoᔲᶇ◚᝞Ḅ᪀⌼ஹḄ!"ᓄஹ$⌕Ḅ&'(஺....$⌕ឋ,-⚗/0ᔲᵨ1234Ḅ5ᩭ⊤89:ᙠ<=>?@ABḄᦪDᡈDFGᙠC++<=>Hᔲᵨconst5IJK5⌕᝞LM5NᐸP5QᑗSᐵHᔲᙠU2>ᒹ1WXᐵYᔲZ[\>Ḅconstᦪ]ᡂᕒ`aconstᦪ]ᡂᕒbᙠcdefᑁ5Hhi᦮c\hkᓾmḄ஺...>ᦪVW$⌕ឋ,-⚗/0nᦪḄoᑏᔲp᦮q⌕rsḕubᑏnᦪḄ\vhḕᶍnᦪxD஺nᦪyxஹz=ᔲᔠᳮnᦪḄcᦪᔲ}?ᔲᵨ\v~ᦪqUḄnᦪᔲḕᶍᦪḄ\vᦪxDN\vᙠ2ᔲ

87$⌕ᔲ:5~┯Z᪗ᙠ5ᵨAnᦪHh┯Z᪗ᵨreiurn஺$⌕ᙠᦪḄ“ᐭᜐ”HᔲᵨassertnᦪḄᨵᦔឋ-$⌕ᵨᵨassert?᝞¡¢£¤N┯Z£¤H¥ὅ§ᯠeᙠḄ©ªMU⌕«AᜐᳮḄ஺$⌕returnᔲᢣᔣ“᪘ᑁe”Ḅ“ᢣ┐”ᡈὅ“°ᵨHHᔲᵨconst±²ᦪḄᏉ´ឋconstmµ¶ᑴ¸¹ᦪḄnᦪஹHº»ᦪḄU2¼Useconstwheneveryouneed”...ᑁe½ᳮ$⌕ឋ,-⚗/0$⌕ᵨmallocᡈnewᵭ¿ᑁeÀ¥HᔲÁᓽ-ᢣ┐ᔲaNULL?Ã■Åᵨᢣ┐aNULLḄᑁeÆ$⌕ᔲaᦪÇ~È᝱ᑁeÊ!Ã■Å:ËÌ!"ᓄḄᑁe«aÍᵨÆ$⌕ᦪÇᡈᢣ┐ḄÎ᪗ᔲÏÐ$⌕È᝱ᑁeḄᵭ¿NÑÒᔲÓÃ■ÅᑁeÔÕÆ$⌕ᔲᨵᦔᙢᜐᳮ“ᑁeὑØ”Ù⚪$⌕ᔲÛᦋ“ᢣᔣ5Ḅᢣ┐”ḄᑁÝ$⌕ᔲABÞᢣ┐᝞Ã1Æᢣ┐ßᨵÌ!"ᓄ஺2ᵨfreeᡈdeleteÑÒᑁeÀ¥H:ᢣ┐àáaNULL஺$⌕ᔲ:malloc/free~new/deleteᵨ?$⌕mallocᔲãZ᝞D⁚ᦪᔲ\våᣚᔲ$⌕ᙠçèNÑÒÈ᝱ᦪÇHnew/deleteḄᔲãZ....C++ᦪḄ²éᱯឋ$⌕ឋ,-⚗/0$ëᦪᔲᨵì2ឋ$⌕ᔲᡂᕒᦪḄ$ëஹ⌚îN◚ïð'FḄ$ëᔲFᔠᑴUḄñ<òᔲᵨᑁὶᦪ᝞ᦪᑁḄJṹö÷øHᦪᑁABùú஺

88K⌕ᔲᵨᑁὶᦪIJKJṹ...!Ḅ᪀⌼>ᦪஹ᪆᪀>ᦪZ[\>ᦪ$⌕ឋ,-⚗/0K⌕ᔲûüñ<òhýC++ñþᘤḕḄᦪ]1^ḕḄᦪ᪀⌼ᦪ]2^ḕḄ᪀⌼ᦪ]3^ḕḄ᪆᪀ᦪ]4^ḕḄᦪ஺K⌕᪀⌼ᦪᔲ⍡!ᓄ#$%K⌕ᔲ&'ᙢ)ᵨ᪀⌼ᦪḄ!ᓄ⊤%K⌕᪆᪀ᦪᔲ⍡,◀#$%ᔲ┯ᑏஹ┯ᵨ᪀⌼ᦪ1ᦪ%K⌕ᦪ23ᑖ567]1^8᩵]2^:;<ᨵᑁ?@A]3^ᑖBCḄᑁ?@ADEFᑴᑁH]4^IJ*this஺ᔲ⍡K⌕56%K⌕ᔲ&'ᙢMᑏNḄ᪀⌼ᦪஹ᪆᪀ᦪஹᦪ%OPQ⚗7]1^NSTUVWXḄ᪀⌼ᦪஹ᪆᪀ᦪஹᦪ஺]2^NḄ᪀⌼ᦪYᙠᐸ!ᓄ⊤\]ᵨXḄ᪀⌼ᦪ஺]3^X^NḄ᪆᪀ᦪY_`aᓽcvirtualᐵefg஺]4^ᙠMᑏNḄᦪhDOPS⌕ijkXḄᦪlᡂᕒKC஺...!ḄhiᱯឋK⌕ឋqr⚗stK⌕ᔲuvVW1wᔠḄyᑣ%]1^{ᙠ|}~BAḄ“2”DEAḄᡠᨵU1ឋkBᨵPDᑣᐕBVWAḄU1ឋ஺]2^{ᙠ|}~ABḄ“2ᑖ”]apartof^,ᑣSᐕBAND⌕ᵨA1ᐸwᔠBo...ᐸ⚪K⌕ឋqr⚗stK⌕ᦪl⚪7a1gḄᦪlᨵ┯ᔩ%

89(2)?ᙠSᦪlḄᔩ%(3)?ᙠSᦪlḄ¡¢ᔩ%K⌕⚪7(1)Ḅ!ᓄᡈḕᨵ┯ᔩ%(2)¥~¦ᡈ§¦ᔩ%(3)Ḅ¨©ªᔩ%K⌕|}ᑨ¬⚪7(1)ᵫ®¨©<¯°±¡¢ᦔᔩ%(2)⊤³´Ḅµᐜ·ᨵᔩ%(3)|}ᑨ¬s¸¹᎔ᔩ%K⌕»¼⚪7(1)»¼½¾ᩩÀS&'ᔩ%(2)Á&½¾(»¼)ᔩ%(3)┯ᙢÃᦋ»¼ᔩ%(4)?ᙠÆÇÈᔩ%K⌕┯ᜐᳮ⚪7(1)ijËÌ┯ᜐᳮᔩ%(2)┯ᜐᳮÍÎᙽ2ÐÑᨵÒÓÔÕÌ%(3)┯ᜐᳮÍÎᙽÖ×ØᨵÙÚᔩ%᝞ÜÝḄ┯^Þ▭┯S2±Dᜐᳮà´S&'áá஺(4)┯ᜐᳮÍÎᙽ“âãä”ᔩ%᝞ᙠÔÔ]ᵨåæçÀèé┯஺K⌕ᦻÀI/O⚪7(1)kS?ᙠḄᡈὅ┯ḄᦻÀËÌï$ᔩ%(2)ᦻÀðS&'Ḅà´ᡭòᔩ%(3)ᦻÀsóᑨ¬S&'ᔩ%(4)Ñᨵ&'ᙢᐵôᦻÀᔩ%

90▬öB.C++/C÷⚪Ö÷⚪øᵨ®ὃrC++/CÍÎᕒḄXÖMÍᢈU஺ᑁH▲®C++/CᵨüÁDSýþᦪls᪀ஹÿᝍḄ஺ὃᡂ᧜ὃḄC++/CḄᳮ᧜ὃḄ!"஺#$%90ᑖ'஺(ὃ)*+⚪ᑗ./0஺ஹᑏBOOL,float,ᢣ┐]'“)”VWḄif஺(10ᑖ)12345“78”:;0,0.0,FALSEᡈὅ“>ᢣ┐AB᝞intDnE“78”FGḄifHI3if(n==0)if(n!=0)JKL஺(ᑏBOOLflagE“78”FGḄifH:(ᑏfloatxE“78”FGḄifH:(ᑏchar*pE“78”FGḄifH:ஹbWindowsNTḄ32C++Y[TsizeofḄ)(10ᑖ)charstr[]="HeHo”;voidFunc(charstr[100])char*p=str;(intn=10;(OP(OPsizeof(str)=sizeof(str)=)sizeof(p)=void*p=malloc(100);(OPsizeof(n)=sizeof(p)=

91RஹT+⚪¡25ᑖUIஹᜮᦻXḄifndef/define/endifYZ[ᵨ?2ஹ#include#include"filename.h”ᨵZ[_`a3ஹconstᨵZ[ᵨ⌶ac(defghiU4ஹᙠC++kXlᵨmCnᘤnpḄqᦪIZ[⌕textern“C”uga5ஹ(TvwhxforyzḄ{|}//x//Axfor(i=0;i

92¢ஹᨵᐵᑁḄ¥ὃ⚪¡20ᑖ¨voidGetMemory(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);)}(©ª«TestqᦪᨵZ[᪵Ḅ¯°a(©ª«TestqᦪᨵZ[᪵Ḅ¯°a+3+3VoidGetMemory2(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);)))(©ª«TestqᦪᨵZ[᪵Ḅ¯°a(©ª«TestqᦪᨵZ[᪵Ḅ¯°a+3+3

93ºஹᑏstrcpyqᦪ(10ᑖ)»¼strcpyqᦪḄ½¾;char*strcpy(char*strDest,constchar*strSrc);ᐸXstrDest;ÀḄÁÂÃstrSrc;ÄÁÂÃ஺(1)lᵨC++/CḄÁÂÃÅqᦪ(ᑏqᦪstrcpy(2)strcpyÆstrSrcḄᑁÈÉᑴᑮstrDest,IZ[Ì⌕char*K¾ḄÍÎ8aÏஹᑏKStringḄ᪀⌼qᦪஹ᪆᪀qᦪÓ8qᦪ(25ᑖ)»¼KStringḄ½¾I3classString(public:String(constchar*str=NULL);//ÔÕ᪀⌼qᦪString(constStringftother);//Ö×᪀⌼qᦪஹString(void);//᪆᪀qᦪString&operate=(constString&other);//Ó8qᦪprivate:char*m_data;//ᵨØÙÚÁÂÃ)¸(ᑏStringḄÛv4xqᦪ஺

94▬ÝC3C++/C⚪Ḅ+ᫀEßᑖ᪗áஹ(âᑏBOOL,float,ᢣ┐DE“78”FGḄifH஺(10ᑖ)(ᑏBOOLflagE"78”FGḄifH஺(3ᑖ)᪗ª«ᫀ.᝞wᑏᙳæçèéêᑖ஺if(flag)if(flag==TRUE)if(!flag)if(flag==1)if(flag==FALSE)if(flag==0)(ᑏfloatxE“78”FGḄifH»(4ᑖ)᪗ª«ᫀrs.constfloatEPSINON=0.00001;᝞w;┯þḄᑏêᑖ஺if((x>=-EPSINON)&&(x<=EPSINON)if(x==0.0):òó}Dᵨ“=="ᡈ"ô=”EᦪÁif(x!=0.0)FGõö÷øᓄᡂ“>="ᡈ“<=”JKûü஺ᑏchar*p“”Ḅif஺(3ᑖ)᪗ª«ᫀ.᝞!ᑏ"ᙳ$%&'()%*ᑖ஺if(p==NULL)if(p==0)if(p!=NULL)if(p!=0)if(p)if(!)ஹbWindowsNTḄ32C++Y[TsizeofḄ)(10ᑖ)charstr[]="Hello”;voidFunc(charstr[100])char*p=str;(intn=10;;<;

95ஹqr⚪¡25ᑖ^IஹᜮᦻBCḄifndef/define/endifDEFᵨHI5ᑖJr■vwᜮᦻJ3Kyzᵨ஺2ஹ#includeK#include"filename.h”ᨵEFMNHI5ᑖJr|}#include,ᘤ᪗filename.h|}#incline"filename.h”,ᘤᵨᡝḄfilename.h3ஹconstᨵEFᵨ⌶HIPQRSTUJI5ᑖJr¡1const2const⛲>ᦪḄᦪஹ\)>ᦪḄ஺3const⛲Ḅᑮ¢ᑴ¤¥)⚜■§᜜Ḅ©5)ª«hMNḄᏉឋ஺4ஹᙠC++WXCYᵨZC[\ᘤ[\^Ḅ_ᦪ)aEF⌕cextern“C”HI5ᑖJrC++T®¯ᢝ>ᦪK±)CT®+¯ᢝ>ᦪK±஺>ᦪ3C++²ᙠ´ḄPµRCT®Ḅ+¶஺ᎷV¸¹>ᦪḄº»¼voidfoointx,inty;w>ᦪ3Cᘤ²ᙠ´ḄPµ¼Cf஺஺)½C++ᘤᑣ2¾¿À_foo_int_intÁ!ḄPµ஺C++«Â(CÃÄÅᣚᢣÇÈextern“C”ᩭÊËPµᓛÍÎ⚪஺5ஹÏqÐÑÒ¹forÓÔḄÕÖס5ᑖ^for(i=0;i

96kஹᨵᐵᑁnḄoὃ⚪(rs⚪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_ᦪᨵEF᪵ḄHTest_ᦪᨵEF᪵ḄHWX஺ṹ஺aGetMemory%⌴᝱ᑁn)aGetMemoryḄᢣᔣ“᪘ᑁn”Test_ᦪCḄstr•—NULL஺Ḅᢣ┐)£ᢣ┐Ḅᙢᙬ%NULL,¦ᐸ¨strcpy(str,"helloworld");WX©Ḅᑁª«¬Z◀)¯ᑁª%°஺஺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_ᦪᨵEF᪵ḄHTest_ᦪᨵEF᪵ḄH¸ᦋ᝱ᑁnMḄᑁª)^º»⚜(1)´µhelloᧇ)¾¿ᓻ◅஺(2)ᑁn¶·afree(str);Â^)strᡂaÄᢣ┐)if(str!=NULL)%ÅÆᵨ஺

97Çஹ[ᑏstrcpy_ᦪ(10ᑖ)«°strcpy_ᦪḄ¨Èchar*strcpy(char*strDest,constchar*strSrc);ᐸCstrDestÉḄÊËÌ)strSrcÍÊËÌ஺(1)%Yᵨ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,aEFÕ⌕char*ÖÈḄHa×Ø©ÙÚ⊤ÜÚ஺//2ᑖÝ᝞intlength=strlen(strcpy(strDest,uhelloworld"));Þஹ[ᑏÖStringḄ᪀⌼_ᦪஹ᪆᪀_ᦪKâ_ᦪ(25ᑖ)«°ÖStringḄ¨ÈaclassString(public:String(constchar*str=NULL);//åæ᪀⌼_ᦪString(constString&other);//çè᪀⌼_ᦪString(void);//᪆᪀_ᦪString&operate=(constString&other);//â_ᦪprivate:char*m_data;//ᵨêënÊËÌ)³[ᑏStringḄìí4ï_ᦪ஺᪗ñᫀ//StringḄ᪆᪀_ᦪString::^String(void)஻3ᑖdelete[]m_data;//ᵫêm_dataᑁôᦪõÖÈ)ö»ᑏᡂdeletem_data;

98//StringḄåæ᪀⌼_ᦪString::String(constchar*str)஻6ᑖ(if(str==NULL)(m_data=newchar[l];//øcNULLᑨúᑣüý*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);)//89.ᦪString&String::operate=(constString&other)//13ᑖ(//(1);<=89஻4ᑖif(this==&other)return*this;//(2)BCDᨵḄᑁHIJ஻3ᑖdelete[]m_data;//(3)ᑖKLḄᑁHIJMNOᑴᑁQ஻3ᑖintlength=strlen(other.m_data);m_data=newchar[length+1];//NULLᑨ"ᑣ$%strcpy(m_data,other.m_data);//(4)RSTUVḄWᵨ//3ᑖreturn*this;}

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

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

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