C基础讲义笔记(干货)

C基础讲义笔记(干货)

ID:83361017

大小:14.35 MB

页数:224页

时间:2023-04-15

上传者:无敌小子
C基础讲义笔记(干货)_第1页
C基础讲义笔记(干货)_第2页
C基础讲义笔记(干货)_第3页
C基础讲义笔记(干货)_第4页
C基础讲义笔记(干货)_第5页
C基础讲义笔记(干货)_第6页
C基础讲义笔记(干货)_第7页
C基础讲义笔记(干货)_第8页
C基础讲义笔记(干货)_第9页
C基础讲义笔记(干货)_第10页
资源描述:

《C基础讲义笔记(干货)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

C++1ஹC++CḄ᡽1ᓫḄC++1.1ᙊḄᕜ☢ᦪᕜ☢ᙳᵨ"#ᦪ⊤%ᦪᜐᳮ(ᐭr*+,ᕜ=2*n*r*+,☢=n*r2;(-ᕜ☢*./1ᵨ0᪀ᓄ./3ᙊḄᕜ☢//countthegirthandareaofcircle#includeusingnamestd;voidmain(){doubler,girth,area;constdoublePI=3.1415;cout«"Pleaseinputradius:

1";஻56789cin»r;஻(ᐭgirth=2*PI*r;

2area=PI*r*r;cout«"radius="«r«endl;cout«"girth="«girth«endl;cout«"area="«area«endl;}2ᵨ☢ᔣᙊḄᕜ☢ᑖ᪆“ᙊ”Ḅτ[ᐹḄᙊ!ᓄ,ᑖ᪆ᙊ<ᡂᕒ$%ᡂᕒ&ᦪ()ᙊḄᕜ☢

3#includeusingnamestd;classCircle{doubleradius;஻ᡂᕒ?@public:஻<ḄABCᑴvoidSet_Radius(doubler){radius=r;}஻ᡂᕒEᦪdoubleGet_Radius(){returnradius;}஻FGᡂᕒEᦪHIᡂᕒ?@doubleGet_Girth(){return2*3.14f*radius;}஻FGᡂᕒEᦪJKᡂᕒ?@doubleGet__Area(){return3.14f*radius*radius;})*voidmain()(CircleA,B;஻ᵨ

41.2XYὅ᧕\┯^_#//demo02_circle_err.cpp#includeusingnamespacestd;஻c++Ḅ`abcclasscircle(public:doubler;doublepi=3.1415926;doublearea=pi*r*r;)*intmain()(circlepi;cout«”f(ᐭarea"«endl;cin»pi.r;cout«pi.area«endl;஻gLṹsystemCpause1');

5return0;O0iᑁklmḄnopqrstu-vwṹᳮprst◤⌕ᡂᕒEᦪ2H+./Ḅzᔊ☢ᔣGḄ0᪀ᓄH+./•H+~-⚔ᔣஹ⌲஺ᵨ_ᙽᑖpM⚔ᔣஹᑖ஺•0᪀-ᢥᑜᑖrST_ᙽᡂ᪛0᪀஺-ᔜ_ᙽcḄᐵᓫQ*¡_ᙽᑁ¢ᙳ£ᵫ¥ஹ⌱§¨©ª«ST0᪀¬ᡂ஺-ᐸ_ᙽᓄ"vḄᐹ¯./£°ᵨ±஺•²³ᨵᦔᙢ·¸¹ᩖḄ»H+¼½ᑖpᡂ¾¿᧕ÀCᑴᜐᳮḄ±¼½ÁÀÂzÃÄ஺•Å³8ᵨឋÇஹᦪÈᐰឋÇஹÊËÂzᜧ#ÍÎÏÐ☢ḄÑᵨÍÎ-ÒᦪᜐᳮᦪḄGᑖÓrÔQḄ"¯஺-Õᦪ0᪀ᦋ?×ᡠᨵᐵḄᜐᳮGÙ⌕ÚÛÑḄÜᦋ஺-¡«ÀὁB⚪Ḅß./Ù⌕àᩭâ᜜ḄÂ├஺-ÏᵨᡝÐ☢ḄÑᵨæÊᵨGᩭ"vÂzÃÄçÙæèÊ஺☢ᔣMḄ./

6•·ᦪéᦪḄ56./êëᙠí6rÔîkஹïᑖÓḄ᦮¯M஺•ñ<#MM-ᐸᐳឋᡂ<஺•Ḅ01&?@>ᵨᩭ-.ABCᱥḄEFGᵨᩭ᪀ᡂ?@ḄHIᓫ஺01ᵫKLឋNK56᪀ᡂ஺-Lឋ&ᵨᩭ-.01☟᝱ᱯ%Ḅᦪ+⚗஺-56&ᵨᩭ-.01/᝱ᱯ%ḄOPQᑡ஺S•ᑖSUSVWḄXY<=•ᑖSᡠZ+Ḅ[ᑣ]1-^ᶍCᱥḄ`Iaᱯ%bcdefghij᪗ᨵᐵḄIaᱯ%mnopCᱥḄᐳឋrᐹᨵᐳsឋaḄCᱥᑜᑖ6Stp]1Ḅᭆv஺-w᝞xᜮஹ᪛ᩈஹஹ}~UᙠḄNE>]1pḄᭆv஺

7•☢ᔣ01<=>Ḅ"S"-ᐹᨵsLឋNḄK01Ḅᔠ-6LSḄᐰ01]1Ḅ-.ᒹLឋN56⌕ᑖ஺-Sg01Ḅᐵ?&᝞ᐹgḄᐵ?L(SḄ01¡6SḄEw஺¢£¤rABCᱥ¢£ᡂ]1ḄS¥¦Sr§¨Ḅᦪ+N<=b©ªḄSᡈὅ01OP0¬ªḄ5ª®◚°஺•r01ḄLឋN±ᔠᡂḄ?@ᓫᐗ஺•³9◚´01Ḅᑁ¶⁚஺0᜜ᡂ¹ᡈὅº⍝¼½b¾ᶇᨵ▲Ḅ0᜜ÁÂÃg᜜Äὶ?஺•ÆÇ0ÈÉᵨᨵḼË⌕dÌ☢ᔣ01ᢈÎ9ÏÐÈÑÄᦔ᳛ḄË⌕[Ô஺•ÕÌ&ᱯÖSḄ01×ᨵᐸÙSḄᐰLឋg¡PᱯÖS0ÙSḄÆÇ஺•w᝞&ÚÛP6ÙSAÛÝᱯÖS஺Þ᝱Þ᝱ᢣᙠÙS>ÕÌḄLឋᡈ56àᱯÖSÆÇáᐹᨵ¬sḄᦪ+Sâᡈ⊤4p¬sḄ56஺ãÃtsLឋᡈ56ᙠÙSäᐸᔜᱯÖS>ᐹᨵ¬sḄæÌ஺☢ᔣ01ḄÈçè•☢ᔣ01ḄÈçè☢ᔣ01<=ᙠÈçè⚞êḄᐰ☢ëᵨ஺Gᒹ&-☢ᔣ01Ḅᑖ᪆00A-☢ᔣ01Ḅí00D-☢ᔣ01ḄîèOOP-☢ᔣ01Ḅïð00T

8☢ᔣ01ḄÈYñOOSMò±&☢ᔣóèèQí&ᦪ+±᪀+õ=⌕ö÷øùõú⚪ᵨᡝ◤þÿᓫᱯᑖ᪆⚪ᡠ◤⌕Ḅᑭᵨᦪᔜᵨᦪ⚪⚪!ᵨឋ#$%ឋ#᪀'Ḅ()*+ᵨᡝ◤-☢ᔣ012345ᵫ78'9:;<78=Ḅ>ᱥ@A᧜Cᑮ23=E@A*+ᵨᡝ◤-ᱯ@Aᑖ᪆ᵨᡝ◤-=FGḄᔜHᙠJṹ=LM78=ḄHᙠJṹ=ᐵὶᔜHPQRS⚪TU᪀'ḄVW〉Yᵨᡝ◤-ḄZ[\ᓄ@Aᑭᵨ☢ᔣ^2_)ḄTU`aᐸcU

93CefgC++efᐵhcefiᙠjḄ^2=⌲lᗐnᩭḄpᨵrst⇋Ḅ45^2vᵨwxᙠyz“ᮞ⁐ᙢ”ᶇ^zefḄᱯ@Aᑭᵨᢣ┐ᑁxSCefḄ᪗iᦔᨬ23᡻ᦔ᳛Ḅᦔ☢ᔣ^2_)☄ᩭzḄ◍Ḅw᎛E8aὃ⇋ᙠR2⚗=¡ᐭ☢ᔣ01Ḅ45_)E£¤◤⌕Ḅ⚪¥iᦔḄ☢ᔣ01efE¦§VW¨©ª«xᙠḄJṹ஺Cef+☢ᔣ01_)===¯ObjectiveC/C++CefgC++¦Zi09Ḅ°±ᐵhC++iCefḄ²³Ei¤´µ¶ḄCefC++i·Cef¸¹ẠḄE¦§lᐰ¨©CefḄᱯឋ¼½C++¦Z¾¿ÀÁᨵḄCefÂÃEÄž᪷Dzr0CḄÈÂɼ½C++·AÊᑮµzḄ45_)E¦ᩭµzḄ˾஺1)C++i¤´µ³ᜧḄC,Í^¼½C++VWÎϵzḄ45_)2)C++iJava/C#/DÐJaÑefḄ¹ẠE¼½C++ÒVWÓÔÎÏÕÖef3)C++iᔜᜧÂ×Øᢧ⌱ÛÜḄ᪗ÝÞ¤

104C++0CḄ²³4.1namespaceß×àá1C++ß×àá¹âãÃᡠänamespace,iᢣ᪗ÃåḄᔜ´æè஺C++᪗Ý23é=Ḅᡠᨵ᪗Ãåêëìí¤׸stdḄnamespace=஺¤iostreamgiostream.hîïZ¤᪵EñὅpᨵÒóE▭õEᙠöḄ÷øᘤincludeᦻᜳü☢·ýᑮEþὅiÿᦻᡭᦻ☢Ḅṹ᪵Ḅ஺ḄᜮᦻC++᪗!ᢝ#$%Ḅ&'᪗()*+,ᙠᐰ/012ᙠ3ḄᜮᦻC++᪗#4C567#89ᵨ;<01=+ᜮᦻ9ᵨ.h஺>?1@9ᵨiostream.hAB@CᙠcDEᵨ(Fᦪ9ᵨḄᐰ/;<017$HḄC++&I2@9ᵨiostreamḄA᎛KᜮᦻLᨵ+,ᐰ/;<01NO9ᵨnamespacestdIP᪵Q*89ᵨcout«R:ᵫCnamespaceḄᭆV9ᵨC++᪗WX(ḄYZ᪗[\A]^ᨵ_`⌱

11c:1ஹefᢣ+᪗[\஺h᝞std::ostreamjostream஺k᦮mn᝞opstd::cout«std::hex«3.4«std::endl;2ஹ9ᵨusingᐵrs஺usingstd::cout;usingstd::endl;usingstd::cin;^WX]^ᑏᡂcout«std::hex«3.4«endl;3ஹᨬwxḄ9ᵨusingnamespacestd;h᝞pusingnamespacestd;P᪵;<01stdᑁ+,Ḅᡠᨵ᪗[\{ᨵᦔ}~ᐝ஺2ᐰ/᪵஺^mn]^᝞oᑏpcout«hex«3.4«endl;>᪗(Ḅᜧᡠ^WXᕒᙠ⌱cḄḄ<ᡈFᦪ

12CDḄ;<01ᙠCmÑDÒᨵᐰ/ÌᵨÇCmÑDᡠᨵḄᐰ/᪗[\ᐳÔÌᵨÇ᪗[\Õ1]*ÃC++D#;<01ḄᭆV;<01'ᐰ/ÌᵨÇᑖᡂḄ×ᑖ;<01DḄ᪗[\]^

133C++;<01ÞW&ßnamespaceNameSpaceA(inta=0;)namespaceNameSpaceB(inta=1;namespaceNameSpaceC(structTeacher(charname[10];intage;)I)intmain()(usingnamespaceNameSpaceA;usingNameSpaceB::NameSpaceC::Teacher;

14printf(za=%d

15z/,a);printf(za-%d

16஻NameSpaceB::a);NameSpaceB::NameSpaceC::Teachert2Teachertl=3);printf(zt1.name$%s

17஻tl.name);printf(z/tl.age=%d

18஻tl.age);system("pause");return0;)4,-1)./ᵨ1iostream3Ḅ5᎛7ᜮᦻ:;ᨵ=>ᐰ@ABCD,EF/ᵨnamespacestdGH᪵JKLM/ᵨcout஺OPQᐭusingnamespacestd◤⌕H᪵U஺std::couto2)C++᪗XYZ[C\]^_YZLM/ᵨABCD`=ᜮᦻ:P/ᵨab.h஺3)C++ABCDḄ=>cnamespacename{...}4)usingnamespaceNameSpaceA;5)namespce=>ijᝅ஺

194.2“mᵨឋ”pqinclude"iostream"usingnamespacestd;஻€cstuḄvwxEFᙠzᵨ{^|Ḅ}~=>஻C++ustḄ“mᵨឋ”ᡠᨵḄvwxiᙠ◤⌕/ᵨ5=>஺intmainll()(inti=0;printfC'ddd");intk;system("pause");return0;4.3registerᐵp“registerᐵᘤvwaᙠᘤ☢஻ᙠcsturegister⛲ḄvwPKᙢᙬᙠC++☢UZᑁ¡/*//I

20registerᐵḄvᓄregisterᐵ“ᘤ”£@¤vw¥¦ᘤuCstu§¨©registervwᙢᙬᙠC++uªᯠ¬ᢝregisterᐵC++ᘤᨵ®¯Ḅ°ᓄ±²P/ᵨregister_iKU°ᓄC++ui©registervwḄᙢᙬ//2C++ᘤ³´µ¶u◤⌕registervwḄᙢᙬ5register·vwḄ¸¹v©§ᦔ஺஻3»¼CstᘤP½·¾ṹÀÁ°ᓄÂÃregistervwÄÅÆÇḄ⊡ᐙ஺*/intmain22()(registerinta=0;printf("&a=%x

21"&a);;system("pause");return0;ᐸË⊡ᐙc▅ÍÎregisterᐵÏÐÑ᜜▅Í.docx3

224.4vwÓÔpᙠcstuÕÖ=>×ÅØBḄᐰ@vwᔠ¨ḄᙠC++uPᐕÛ=>×ÅØBḄᐰ@vwCstu×ÅØBḄᐰ@vwᨬݽÞßᑮᐰ@ᦪâ\ḄØÄÅᙢᙬCDãintg_var;intg_var=1;C++äåHæ$>ឋḄU¨஺*/intmain(intargc,char*argv[])(printf("g_var=%d

23",g_var);return0;)4.5structçèqstructçèḄqcCstḄstruct=>ZÄévwḄêᔠCᘤëPìYHÄæíḄçèC++uḄstructÄÅíçèḄ=>¸¹structStudent(charname[100];

24intage;);intmain(intargc,char*argv[])(Studentsi={"wang",1};Students2={"wang2"2};zreturn0;)4.6C++uᡠᨵḄvw[îᦪxEFᨵçè/*C++uᡠᨵḄvw[îᦪxEFᨵçèCstuḄïìçèᙠC++uPᔠ¨ḄîᦪfḄðñòóôçèõᦪöóôçè÷îᦪgiø×ùÅõᦪ÷7஻ᣚᡂ.cppüüf(i)

25printf("i=%d

26"i);zg()(return5;)intmain(intargc,char*argv[])(f(10)Gprintf("g()=%d

27",g(l,2,3,4,5));getchar();return0;)ý,c/*ᙠcstuintf()G⊤int,ᦪḄᦪ

28intf(void)⊤intḄᦪᙠC++intf()^Mntf(void)ᐹᨵḄ⊤intḄᦪ*/C++!Ḅ"#ᐗ%&'(ᢣ*!4.2-4.6+,-./0Ḅ1஺4.731Bool!ᐵ56C++Ḅ78!C++ᙠC-9Ḅ:;!<=>?1@boolC++ḄboolABḄCᨵtrueDfalseᳮF?boolCᓰᵨIJ6⁚᝞MNJboolOPQᙠIRASTᔜᓰIJbit,VBW,XYᘤḄ[\true]⊤^XYᘤᑁ`ᵨ1ᩭ⊤false]⊤b^XYᘤᑁ`ᵨ0ᩭ⊤bool!Cᨵtrue(b0)Dfalse(0)dJC++XYᘤTᙠefgb0hᣚtrue,0hᣚfalseintmain(intargc,char*argv[])(inta;

29boolb=true;printf("b=%d,sizeof(b)=%d

30"b,sizeof(b));b=4;a=b;printf(Ha=%d,b=%d

31",a,b);b=-4;a=b;printf("a=%db=%d

32"a,b);z/a=10;b=a;printf("a=%d,b=%d

33"a,b);/b=0;printf(Hb=%d

34"b);/systemCpause'*);return0;

354.8jklmnoS11jklmnᙠCDC++XYᘤḄ⊤\intmain()(inta=10;intb=20;஻IJᨬrᦪstuᨬrᦪeᡂ3஻jklmnwIJ⊤xy⊤xyzAS{|(a

36",a,b);system("pause");return0;2}F1)c-9OPḄC++-9wOP;~C-9ḄjklmnḄwOPzS|ᵨC++ḄjklmnAOP;~A\ᙠ"#Ḅᙢ2)jklmnASḄ᝞MᨵIJwPᑣzS|ᵨ(a

373)C-9᝞ᢝC++Ḅᱯឋᕖ====|Ḅᩩ⌕ᨵᑁC++XYᘤ"#ᕒB@IJᙢᙬ¡¢£ὃ᝞¥CḄjklm.|ᕖ5C/C++Ḅconst1const:Ạ§¨(ᵨ.ஹªஹ«ᜐ)intmain(){constinta;intconstb;constint*c;int*constd;constint*conste;return0;}Intfuncl(const)®/ᳮ¯constwQP°±constᕡḼC´ª஻µIJµ°J£I᪵]⊤IJ᦮¸ᦪ஻µjJCwIJᢣᔣ᦮¸ᦪḄᢣ┐(ᡠᢣᔣḄᑁᦪ¼zS½¾ᦋÀw;~A¾ᦋ)

38஻µÁJdᢣ┐Âᢣ┐OPzS½¾ᦋÀwÃᡠᢣᔣᑁA½¾ᦋÄ஻µÅJeIJᢣᔣ᦮¸Ḅᢣ┐Âᢣ┐DÃᡠᢣᔣḄᑁᙳzS½¾ᦋÄConst«ᜐ஻ᔠᳮḄᑭᵨconst,஻1ᢣ┐{ᦪᦪAᨵᦔḄÊË]ṹA´ឋÍÎbug//2ÏÐḄᑖÏᦪḄÒᐭDÒᱯឋintsetTeacher_errconstTeacher*pConst¾ᦋ¸Ḅf᎛ᙠᑭᵨ¸zS¾ᦋᢣ┐ᡠᔣḄᑁ2c“ᑈ×Ø”intmain(){constinta=10;int*p=(int*)&a;printf("a===>%d

39"a);/*p=ll;printf("a===>%d

40"a);/printf("Hello……

41");return0;¯ÚC++XYᘤÛconstPḄᜐᳮ

42ÜÝPÞ*fᙠnß⊤àᐭPá⚪ãᨵ᝞¯ÚBᙢᙬXYä"åæ\ᵨPᑣnß⊤ḄçᣚXYä"åæ\Ûconstᵨ@externᡈὅ&ënᑣuÛìḄPᑖíî(ïðC)?ὶóint&a=l(err)&constint&a=10(ok)?C++constnß⊤ôᳮõC++XYᘤöᯠASconstPᑖíÀzTᵨᐸîḄ஺}FC-9ḄconstOPC-9constOPwC´OPᨵùúḄîC++ḄconstPASᑖíîûASzᑖíîconstPᐰýst◤⌕ᙠᐸÃᦻᵨᵨ&constḄᙢᙬ3const#(16116ᜐ஻//#defineN10

43intmain()constinta=1;constintb=2;intarray[a+b]={0};inti=0;for(i=0;i<(a+b);i++)(printf("array[%d]=%d

44“,i,array[i]);)getchar();return0;C++Ḅconst⛲Ḅ"#$%&'Ḅ"()#C*+,-.஺ᙠconst⛲Ḅ1234"56789:ᩭ<஺4const#+=116Ḅ>?U@ABCC++ḄconstDEFG9Hconstintc=5;#definec5C++ḄconstIG9H)

45const#ᵫ12ᘤᜐᳮḄ"MNDOPQᵨRPQG9Hᵫ⚜ᜐᳮᘤᜐᳮ"ᓫUḄᦻWXᣚ஻ᙠfund9Ha,ᙠfunc2Zᵨᔩ\஻ᙠfund9HḄb,ᙠfunc2Zᵨᔩ?voidfunl()(#definea10constintb=20;//#undefa#undef)voidfun2()(printf("a=%d

46"a);///printf("b=%d

47",b);}intmain()(funl();fun2();return0;)

485^_C`aḄconst*C`aconst*#,-*"ᨵcdḄefg4C++ḄconsthZᑖjefg4"khZ)ᑖjefg4constᐰm"no◤⌕ᙠᐸsᦻᵨ"tᑖjefg4ᵨ&"constḄᙢᙬu"tᑖjefg4constint&a=10;const⛲vᵨu"ktᑖjefg46vᵨw⚪yz1vᵨ+{|vᵨ.*}~*}#$efg4Ḅ}"#$%᪗+.|*ᩭᵭn}ᑁeg4|*Ḅ}hᵨefg4⚪1@$Ḅᑁeg4,Z$%}ᔩ\1vᵨᭆaᙠC++B

49d)vᵨᦪᦪ\(vᵨᦪᦪ¡¢u)£¤¥¦ᓄ)voidmain01()(m13©10஻ª12ᘤᑖj4%⁚ᑁe஺஺஺aᑁeg4Ḅ}int&b=a;஻b5#aḄ}஺஺஺a©11;஻¬®¯(int*p=&a;*p=12;printf(na%d

50",a);)b=14;printf(na:%db:%d”"a,b);system("pause");2vᵨ#C++Ḅᭆ°FC++12ᘤ@cḄ᡽²⚪Ch12|ᔩ\intmain()(inta=0;int&b=a;//int*constb=&ab=11;//*b=11;

51return0;^_)⌕ᵨCḄ`ὃ⇋b=ll3vᵨᦪᦪ{|vᵨᙠ¡¢uµ¶ᵨᐸsḄ*£¤¥¦ᓄ,vᵨᦪᦪ¡¢u)£¤¥¦ᓄ஻05¸ᩖᦪºDOḄvᵨstructTeacher(charname[64];intage;};voidprintfT(Teacher*pT)(cout«pT->age«endl;)஻pT#tlḄ}"Fᦋ

52pT.age=33;஻pTtlḄ#¼%)Ḅ*voidprintfT3(TeacherpT)(cout«pT.age«endl;pT.age=45;஻,tᦋpT*")tᦋtl*)voidmain()(Teachertl;tl.age=35;printfT(&tl);printfT2(tl);஻pT#tlḄ}printf("tl.age:%d

53",tl.age);//33printfT3(tl);//pT#½,tlcopy$¾ᦪº¿pT//—>pT=tlprintf("tl.age:%d

54",tl.age);//35cout«"hello..."«endl;system("pause");

55return;4*ᵨḄ+,1)vᵨᐸs*Ḅ}(eᙠ"ÀÁᙠ$ÂÃᔠhªXᢣ┐2)vᵨ@Fᢣ┐ᩭÇᐹᨵÉÊḄh-ឋᵨឋBintswap2(int**a,int*b)Elintswapl(int&a,int&b)((intt=*a;intt=a;*a=*b;a=b;*b=t;b=t;return0;return0;))5*ᵨ-./ὃÌὃLC++12ᘤÍÎ<Ï\intmain()(inta=10;int&b©a;஻13#@Ḅ}"C++12ᘤÎ☢<Ï\b=11;cout</"<

56஻"a);

57printf(஻b:%d

58஻"b);printf("z&a:%d

59z",&a);printf(஻&b:%d

60஻"&b);஻Ìὃ@$ᑁeg4hÊð%}ᔩ\system("pause");return0;}ᓫõ9HḄvᵨu"µ¶¥¦ᓄöÇ¢÷ø$%Ìὃ2{|vᵨᨵcdḄg4ᔩ\structTeacer{int&a;int&b;}öintmain(){printf(/Zsizeof(Teacher)%d

61஻"sizeof(Teacer));system("pause");return0;}vᵨ#$%ᨵᙢᙬ"vᵨ#஺஺஺஺஺char*constp6vᵨḄW1)vᵨᙠC++Ḅᑁþÿᢣ┐Type&nameWfType*constname

622)C++ᘤᙠᵨᢣ┐ᵨḄᑁᵨᡠᓰᵨḄᜧ!ᢣ┐"#஺3)%ᵨḄ&'ᵨ()*+(ᐸ-./0ᨵ23Ḅ45஺6C++7ᵨឋ9:;Ḅ<⁚◚?voidfunc(int&a)voidfunc(int*consta){{a=5;*a=5}}Intmain()(intx=10;func(x);)4)BC

63mᦪHᵨn᪘QReᡂᐸᵨḄHeHᵨ☟᝱QRᡈᐰQRᡂᐸᵨḄHᓽHᵨHᵨC++ᵨᑮᵨ¡¢£¤¥¦⚪H¨Ạª«mᵨintgetAAl()(inta;a=10;returna;)஻¨Ạª«aḄn᎛(ᨵ¬int&getAA2()(inta;a=10;returna;

64int*getAA3()inta;a=10;return&a;HstaticQRmᵨ“static`⛲QRḄn᎛QR¯᝱QRintj()(staticinta=10;a++;printf("a:%d

65",a);returna;(staticinta=10;a++;printf("a:%d

66H,a);

67returna;int*j2()(staticinta=10;a++;printf("a:%d

68"a);zreturn&a;voidmain22()(஻°Ḅ¡¢b±ᦪH0ᨵᑁ4ᙢᙬemH஺஺஺஺஺//II=100;//*(a>b?&a:&b)=111;஻m²³ᵨḄᦪmHḄn᎛´µᵨ஺஺஺஺஺jl()=100;஻ᘤpᡃrᡭ⌼7¸᛻jl()º*(j2())=200;஻"m»ᡃrsᕒuvḄᡭ⌼:HḄᩩM12()ºsystem("pause");

69HUTmᵨintgl(int*p)(*p=100;return*p;)int&g2(int*p)//(*p=100;return*p;஻mᡃrᵨᵨwxḄn᎛ᡃre_ᐵyᘤᵨz{:Ḅ஻mᡃrᑖ᪆¼ṹ6¾Ḅn᎛ᡃr_ὃ⇋C++ᘤz{:Ḅ஺஺஺஺voidmain23()(intal=10;al=g2(&al);int&a2=g2(&al);஻ᵨᵨ_F¿ᦪḄHe¼ṹᐵÀÁḄᑁ4e²ᘤᦈ7஺஺஺஺

70printf("al:%d

71"al);zprintf("a2:%d

72",a2);system("pause");HèẠª«structTeachar(charname[64];intage;º஻᝞±ᵨe¨Ạª«ªÅ{ÆÇÃGH஺஺ÈÉᑮcopy᪀⌼ᦪj=̤¥ÍẈ஺஺஺஺structTeachar(charname[64];intage;º஻᝞±ᵨe¨Ạª«ªÅ{ÆÇÃGH஺஺ÈÉᑮcopy᪀⌼ᦪj=̤¥ÍẈ஺஺஺஺structTeachar&OpTeacher(structTeachar&tl)

739ᢣ┐ᵨ#include"iostream"usingnamespacestd;structTeacher(charname[64];intage;);intgetTe(Teacher**myp)(Teacher*p=(Teacher*)malloc(sizeof(Teacher));if(p==NULL)(return-1;)memset(p,0,sizeof(Teacher));p->age=33;

74*myp=p;//return0;)஻ᢣ┐Ḅᵨ9ÏintgetTe2(Teacher*&myp)(mypk(Teacher*)malloc(sizeof(Teacher));myp->age=34;return0;}voidmain333()(Teacher*p=NULL;//getTe(&p);getTe2(p);printf("age:%d

75",p->age);system("pauseH);2ᵨÐ☢ÒÓᐭconstᵨ

761ᵨQRᓄconstᵨÖὃcostint&a=bPKconstint&a=10;????æ⚪gconstᵨᙠC++çèconstᵨconstType&name=vargconstᵨ)QRéᨵ-êëឋᫀí1gintmain()(inta=10;constint&b=a;//int*p=(int*)&b;b=11;//err஻*p=11;஻-ᵨᢣ┐ᩭᦋQ7cout<<zb--->zz<

77z,a);printf("b:%d

78”,b);printf&a);printf(&b:%d

79&b);,system("pause");return0;}

80ᫀ2voidmain41()(inta=10;constint&b=a;஻const'ᵨ)ᵨ*+a,-ᓄa=11;//b=12;஻01'ᵨ2ᦋa,4•672ᦋ68system("pause");)structTeacherl(charname[64];intage;);voidprintTe2(constTeacherl*constpt)()“const'ᵨB*+(ᡠᢣᑁFGH)IᨵKLMឋ

81voidprintTe(constTeacherl&t)(//t.age=11;)voidmain42()(Teacherl11;tl.age=33;printTe(tl);system("pause");)21ᵨ2☢%3%45ᓄconst*ᵨQὃ1ஹᵨ*+4const'ᵨ,-ᓄconst'ᵨᑖUᑁFGH8ᔩW2ஹᵨX+4const'ᵨ,-ᓄconst'ᵨᑖUᑁFGH8ᔩWvoidmain()(constintb=10;printf(z/b:%d/z,&b);//int&al=19;᝞\6]const^_ᜫaconstint&a=19;printf(z&a:%d

82஻&a);

83system("pause");)3bᔠᫀvoidmain()(஻d0'ᵨinta=10;int&b=a;஻X+'ᵨB*+'ᵨKLMឋconstint&c=a;஻X+'ᵨ,-ᓄᑖefg//Iᵨ*+,-ᓄX+'ᵨ(intx=20;constint&y=x;printf(ny:%d

84y);)//2ᵨX+,-ᓄX+'ᵨ(஻int&m=10;஻'ᵨhᑁFGHḄjkl☢+10nᨵᑁFGHnᨵopq'ᵨ

85constint&m=10;)cout«nhello..."«endl;system("pause");return;3const'ᵨrs1Const&intetuvconstint*conste2d0'ᵨtuvint*constel3u)ᵨX+wl☢+x4const'ᵨyz,-ᓄ{C++^_ᘤ}eX+~ᑖUGH'ᵨkeGHḄjk4)ᵨl☢+4const'ᵨ,-ᓄᡂKL*+4const2⛲5bᔠint&j()(staticinta=0;returna;)

86int&g()(inta=0;returna;}intmain()(inta=g();int&b=g();j()=ioprintf("a=%d

87"a);/printf("b=%d

88"b);/printf("f()=%d

89"f());zsystem("pause");return0;)7C++4CḄᦪ᡽1inlineᑁὶᦪC++ḄconstX+Xᦪ᝞constintA=3;¡#defineA3C++hᔲᨵ£¤oᫀṹᱏᕖW(ṹᱏ¨©ªḄ«ᵨ¬)C++₞)ᵨᑁὶᦪṹᱏ

90C++)ᵨinlineᐵ°l±²ᑁὶᦪᑁὶᦪ±²{inlineᐵ°l³´µᦪrᔠᙠ7ᔲᑣ^_ᘤ}¸¹ºᶍᑁὶ¼½஺஻ᣚµᦪÀᵨÁj#include"iostream"usingnamespacestd;#defineMYFUNC(a,b)((a)<(b)?(a):(b))inlineintmyfunc(inta,intb){returna

91",a);printf("b=%d

92",b);printf("c=%d

93"c);zsystem(npause");

94return0;Ʋ1:³´inlineintmyfunc(inta,intb)µᦪÇḄÈÉ,ᑏᙠᙽƲ2C++^_ᘤᦪyzᑁὶ^_ÌC++^_ᘤᑁὶ^_ḄᦪÍqᑁὶᦪᑁὶᦪᙠᨬÏᡂḄṹhnᨵḄC++^_ᘤ¸¹ᦪÇÐᐭᙠᦪÀᵨḄᙢoᑁὶᦪnᨵd0ᦪÀᵨ{ḄÓ᜜Õ├(×᪘ÙÚÛÜ)Ʋ3C++^_ᘤ6ÝÞᦪḄᑁὶ¼½¬Æ²4ᑁὶᦪhgᱯàḄᦪᐹᨵd0ᦪḄᱯâ(ãᦪäåÛÜæç)ᑁὶᦪh4^_ᘤḄg¼½èé^_ᘤêëìg¼½ᑁὶᦪᵫ^_ᘤᜐᳮ¸¹^_ḄᦪÇÐᐭÀᵨḄᙢoṹᱏᵫ⚜ᜐᳮᘤᜐᳮyzñᓫḄᦻôᣚnᨵõö^_1Ʋ5ÉC++^_ᘤê÷yz^_øᓄèéùᦪᓽ)nᨵinline±²ûêÌ^_ᘤᑁὶ^_ü᜜ùÉC++^_ᘤýþ8᡽ÿᦪᑴᑁὶ᝞g++Ḅ_attribute_((alwaysjnḄe))ឋ6C++ᑁὶḄ▲ᑴᙠḄ!"#ᙠ$%Ḅᩩ'ᑨ)"#

95ᦪ+$,-ᜧᦪ/ᙬ12ᦪᑁὶ345ᙠ6ᵨ"#89ᘤ,ᑁὶᦪḄ▲ᑴ;<=Ḅᑁὶᦪ>,?@ᦪḄABC<ḕEFᦪ6ᵨGH᪘JKLMNḄO├஺RSTᦪ+Ḅ᡻O├Vᜧ,H᪘JKLMNᡠᵨḄO├GXYᑁὶZ[\]஺^_1)ᑁὶᦪᙠG`aZᦪ+bᐭᦪ6ᵨḄᙢe2)inlineC

96*/஻nopᦪvoidprintAB(intx=3)(printf("x:%d

97",x);)஻ᙠnopᦪᑣ᝞¥nopᦪ¦§XY¨©Ḅ£45ᨵnopᦪvoidprintABC(inta,intb,intx=3,inty=4,intz=5)(printf("x:%d

98",x);)intmain62(intargc,char*argv[])(printAB(2);printABf);system("pause");return0;3ᦪᓰ«pᦪ/*ᦪᓰ«pᦪ

99ᓰ«pᦪCᨵpᦪ¬3®xᨵpᦪ¯3f°±²³ᙠᦪ+ᑁ[¢ᵨᓰ«pᦪ*/intfuncfinta,intb,int)(returna+b;}intmain01()(஻func(l,2);஻qrᔩµprintf("func(l,2,3)=%d

100",func(l,2,3));getchar();return0;4nopᦪLᓰ«pᦪqrZᓰ«pᦪ¶nopᦪ^ᔠ¸ᩭ¢ᵨ\]srº»Ḅ᡽½ᶇ³¿À

101ÁÂC"ú»q¦§Ḅᑏ*/஻C++qr3ᓰ«Æpᦪᓰ«Æpᦪf°ᵨ,º»᡽½LC~ṹḄÁÂintfunc2(inta,intb,int=0)(returna+b;)voidmain()(஻᝞¥nopᦪLᓰ«pᦪᙠf¸£6ᵨ¸ᩭfunc2(l,2);func2(l,2,3);system("pause");^_஻᝞¥nopᦪLᓰ«pᦪᙠf¸£6ᵨ¸ᩭ5ᦪÈÉ(Overroad)ᦪÈÉᭆË1ᦪÈÉᭆËᦪÈÉ(FunctionOverload)ᵨÌfvᦪ¯j]ÌḄᦪTᦪ¯LÌḄpᦪÍÎGᦪḄÏ]Ì2ᦪÈÉḄᑨ)᪗Ñ

102ᦪÈÉÒÓÔÕ³☢Ḅfvᩩ'pᦪvᦪÌpᦪ¬ÌpᦪÖ»Ì*/3ᦪMNw<ᦪÈÉḄᑨ)᪗Ñ×Ø16ᵨ±²ᑖ᪆Ú×Ø2ᑨ)᪗Ñ஻ÛvÜÝÈÉᦪLnoᦪpᦪÞÍÈÉᦪLᦪᢣ┐/*intfuncfintx)(returnx;}intfunc(inta,intb)(returna+b;}intfunc(constchar*s)(returnstrlen(s);

103intmain()(intc=0;c=func(l);printf("c=%d

104”,c);c=func(l2);zprintf("c=%d

105"c);/c=func("12345");printf("c=%d

106",c);printf("Pressentertocontinuegetchar();return0;)*/

107ᦪÈÉḄ6ᵨÑᑣᘤ6ᵨÈÉᦪḄÑᑣZᡠᨵ̯ᦪ2s᎛⌱ὅãäåæqḄ᎛⌱ᦪçèᓛÎ×p@$nopᦪᓛÎ×p@$no¬KᣚᓛÎ×pᓛÎᜫìᨬîåæᑮḄq᎛⌱ᦪðfᑣ¦§ñ]ឋᜫì஺[ᓛÎᡠᨵ᎛⌱ὅᦪòj]ᜫì஺ᦪÈÉḄó\ô⚗ÈÉᦪᙠö÷ø<>ùúûḄÌᦪü☟᝱ÿᦪḄᦪḄᦪᦪḄᦪᵫᦪᦪᑡ⊤Ḅ஺ᦪᙠ!"#☢ᦪ⍗&ᦪ'(ᦪ஻*ᦪ'(ᦪ⍗&ᦪ+,-

108intfunc(inta,intb,intc=0)returna*b*c;)intfunc(inta,intb)(returna+b;)//I!ᦪḄᐕ/ᔩintfuncfinta)(returna+b;intmain()(intc=0;c=func(l,2);஻1ᙠ23ឋ56ᵨᜫ95:;<

109printf("c=%d

110"c);zprintf(nPressentertocontinuegetchar();return0;}7ᦪᦪᢣ┐@ᔠᦪBᦪᢣ┐*CᵨᦪDᦪᢣ┐EFGH᪷Jᑣᢧ⌱Bᦪᢣ┐ᦪᑡ⊤NḄ᎛⌱ὅQRᓛT᎛⌱ὅḄᦪBᦪᢣ┐Ḅᦪ*//*intfuncfintx)//intfinta)(returnx;intfuncfinta,intb)

111returna+b;intfunc(constchar*s)(returnstrlen(s);)typedefint(*PFUNC)(inta);//int(inta)intmain()(intc=0;PFUNCp=func;C=Pপ=printf("c=%d

112"c);zprintf("Pressentertocontinuegetchar();return0;)*/

113&ᦪ@Aஹ@ᑏஹ@D,UVWX஺8▬Z▬Z1C++[\DC[\᡽ᐙ_`ḄabᐹddeᙠCFGᙽIJḄKL/*ExplanationSentence*/ḄMẠOC*+FGQRSTUVḄᓫXIJKLY//ExplanationSentenceᓽᵨ⊤\I]5^_`(aᑮcdXefḄᡠᨵ2ijklmIJ஺opqᓫḄrsY/*t☢Ḅuvwx^1ᑮ10஺Ḅ᦮ᦪez{|ᙠ$%swn}*/sum=0;஻$%sum4)(mfor(i=1;i<=100;i++)(஻]5sum+=i//i

1142.ᮣḄ$%ᙠḄCFG}$%Ḅ}ᙠ᡻XṹḄd☢ᦪF᡻XFḄᔠ*┯.¡ᙠC++}¢£ᙠuṹᙽḄ¤¥ᙢ§X$%Ḅ.¨᝞t☢ḄᔩᙠcFG}«¬ḄᙠC++FG}ᓾ¢£¬3¯X.for(inti=1ti<=100;i++)y°᪵²Ḅ³ᜐ1$%ḄD,µḄ1ᵨ}ᙠT+,T¶Sᯠ஺3.¸¹Ḅ&ᦪºC++»¼SCFG&ᦪº½+qᓄḄL°Uqᓄ¾¿CFGu┯Ḅ᪷Á஺C++FG⌕ὅm&ᦪQRÄ᦮ḄºᒹÆᐰÈᦪḄÉÊ)Ë.r᝞ᨵ2iÌÍÎÏpÈᦪஹÉÊ᦮)Ḅ&ᦪ3ºÐ_ᑏmYintf(char,double);¡CFG}ᐕ¾°pºᑏᡂ/()=".ᙠ&ᦪº}ÈᦪÓ¢ᨵ¢ÔÕÖ¢£&ᦪD,}ḄÈᦪÓ«T×.4.ØS&ᦪ@AÙᑴ@AuFG⚞ÜḄ@⌕ᭆÞ஺3ßFG}ᨬᐺḄrs“+ஹ-ஹXஹ/“ãᔜUåæ¯åiḄ@A°çi袣éêᵨᩭ⊤\¿UᦪìíḄ¯î°UTpÓ2ᡈ1pièñò¿@+,Ḅóôõö@A.C++FGØSCFGᡠ÷ᨵḄ&ᦪ@AÙᑴ.Tp&ᦪÓ¢£øù¿p&ᦪD,ú⌕°çD,¢£ûüÈᦪpᦪᡈḄ«éýþ]ᩭᓽ¢.C++ÿᐕ⚜ᐜḄḄ.᪵Ḅᙠ!"Ḅ#$%&'%()ᑏ+ᩭ-./ᯠ.5.1ᦪ3ḕ5ᦪC++ᐕ1ᦪᨵ3ḕ5ᦪ.ᡠ83ḕᢣ1ᦪ:ᵨ&<=>?@A▭Ḅ5ᦪC.D☢FGᨵ3ḕ5ᦪḄ1ᦪḄAHIintf(inta,intb=l)(returna*b;}J1ᦪ:ᵨf(3,1)Kf(3)LMNO᪵ḄPQ.8,Rᐭ/R@UVᑴC++YZ[C]^᪗`aᔜcRᐭ/R@1ᦪdefg[FᝅḄRᐭ/R@Vᑴ-FUVᑴ஺k᝞ᔣ᪗`R@R@FGnoIcout«"C++isbeautiful!ᡈὅᵫ᪗`RᐭsFG᦮ᦪu?#$ainta;cin»a;U)Rᐭ/R@vwx᪷z#$!"/{|ᦪz}ᣚḄᣚ-)<=>ு”Ḅᡃ-.[ὅ/!"ḄᦪzḄRᐭ/R@஺

1159.ᵨ▲%IIᵨ▲%IIᵨᵨ᜜ḄO#$.H᝞ᙠD☢ḄHᡃ<=ᑭᵨIIAᙠ#$ᵨᑁᐰ#$.#includeᦪ?@(ᘤ5ᑮᑁ,CPLBCDᑁᡭF⍝஺!,⌕IJḄKL:%&'NOḄᜧP,C@QRᯠ7NOḄFSḇT(ᘤU!VWXNOYZ[஺K\ḇ]^ᨵ`a%&'K\CPUb]cᨵde(ᘤfgḄCPUhᨵ(ᘤḄᦪiK᪵஺

116kᖽ⌕!mno1pqrk1p஺(ᘤᐸtKᙽKᙽ%Ḅvwxy@ᐸ91p⌕zᑁ{|e஺}~ᐜ|ᨴXCPUdCPUKP"ᑮᦪ*zᙠᜧḄKᙽᑁ,\ᙢᙬḄᦪ{e*ᨵᯠX1p{ᡃḄᑁᦋᡂ(ᘤ|*ᕑ஺ᡃ⌕IḄᨵqஹregister¥⛲§ᨩ©ª«¬®Ḅ¯i°±⚣³ᙢ´ᵨ᝞·]^Ḅ¸®°ᐸ¹ᙠCPUḄ(ᘤºc»{ᐸv1p஺᝞¼☢Ḅᑁᙽ¾¿ÀṹttifdefNOSTRUCTASSIGNmemcpy(d,s,1)(registerchar*d;registerchar*s;registerinti;while(i-)*d++=*s++;}ttendifßஹ´ᵨregister¥⛲§ḄàáLT´ᵨregister¥⛲§ᨵâL▲ᑴ஺✌ᐜregister¯iæç^±CPUᡠCéḄêf஺!?ëáᕡḼregister¯iæçK\ᓫ\Ḅïðñòp®ó%ᡈὅö᦮fḄòp஺@ᨵaøᘤḄ(ᘤb^5ùLᦪ஺ᐸúrkregister¯i]^5ᙠᑁºᡠc^ᵨᩭû9register¯

117iḄᙢᙬ஺ᵫ(ᘤḄᦪiᨵ▲ýña(ᘤy^CéᱯÿḄᦪ᝞ᢣ┐ᦪᵨḄregister⛲ḄᦪḄ!ᘤ#$%&'Ḅregister⛲()*+ᡠ-ᶍ஺ᙠ123456789:ᙠ;:ᘤ<=#>?@ḄAB஺C)ᓰᵨḄ;:ᘤEFGᵨᐸIḄJᡈὅ78)MᵨḄNᦪEO&EPQRᐭ:T78ᡠUᩭḄW᜜Y├஺[\ḄC*+E>6789:ᙠ;:ᘤ<◀^_`aIb᪵dberegister⛲fCghḄijkᨵmnḄ⊡ᐙ஺ᯠ#rḼ*+tuᢈwḄxyᙠz{|278}~):ᑮ;:ᘤ-ᶍregister⛲CIᐰᔠIfᨩ#Ef`a஺9ᓄ1ᩖᦪᵨdᦪᦪᑖ᪆ᑁ:¤¥7ᓄ¦2§ṹ᦬iª3tui«¬ᙊ®Ḅᕜ°4tui«±²,´ឋᨵ¶·±¸,¹Qº¶·±¸»n¹Q¼±²Ḅ¶·±¸

118

1192ஹ¾¿1^C++±ÀᢈwÁÂ᪗ẆÅC++*+ᘤᳮ¾¿ḄÇ===ÉÊËÌÍC++*+ᘤ¾¾¿Ḅ²`ᕜ\ᳮ¾¿ÎÏஹMᵨஹ├ÐC++☢ᔣ¾¿ÓÔÕC++☢ᔣ¾¿&᝱×ᳮÕÅØÙÚC++ÛẠݱÀÞQßᨵàᨵi«᪗áᩭᑨãäåᨵàᨵᐭæ஺☢ᔣç¿èé*C++☢ᔣ*êëìᐹ..☢ᔣç¿*☢ᔣèé/ðñᑖò

1202¾¿2.1Ûôᭆö1ஹ¾¿ஹᡂᕒ78ஹᡂᕒᦪ2☢ᔣ¾¿øᜧᭆöúRஹûüஹ&᝱3*ýḄ{þ¾¿Ḅ{þ¾¿ḄMᵨ¬ᙊ®Ḅ☢ÿTeacherᡭᓺTeacherḄḄḄᑖ2.2Ḅ1EncapsulationA☢ᔣᨬ!Ḅᱯឋ஺ᦪ&'ឋ(ᦪ)*ᔠᡂ-.᦮01ᙠ34567ᵨ9Ḅ஺B:;<ᱥᡂ>Ḅ?@ABCDḄᦪ&EFGHAḄᡈὅ)*KAḄLM◚O஺ᜓ:ᨵ2ឋឋᑴC++7ḄᡂᕒQRC++7ᵨS⊤U'ឋḄQRᡂᕒ(ᦪC++7ᵨS⊤UMVḄ(ᦪ2ᡂᕒḄWXYᑴᙠC++7AB[ᡂᕒQRᡂᕒ(ᦪWX\]Public^⛲ᡂᕒQRᡂᕒ(ᦪABᙠḄᑁaḄ᜜acWXPrivate^⛲ᡂᕒQRᡂᕒ(ᦪGdᙠḄᑁacWX

121஻'ឋEFfgLMWXYᑴ஻ḄᑁaḄ᜜a஻ᡃi>j-.ᵨk஻-.ᦪ&l>Ḅ஻-.ᐹ0ḄQR஺஺ᓰᵨᑁopq஺classCircle(public:doubler;doubles;public:doublegetR(){a++;returnr;)voidsetR(doubleval)(r=val;)public:doublegetS()஻rstudgᙠ^ᦋ^ᦋ7Ḅ'ឋᡈὅEFs=3.14f*r*r;

122returns;)//private:inta;3structclassᐵxyz]ᙠᵨstructgᡠᨵᡂᕒḄ}~'ឋVpublicᙠᵨclassgᡠᨵᡂᕒḄ}~'ឋVprivate2.3C++☢ᔣ᪗☢ᔣᔣ☢ᔣQὅ⌕0qḄᐵ?〉ᫀ1E0cube,E0Ḅ☢0.E0ᔲ¡¢ᐰ¤(ᦪᡂᕒ(ᦪᫀ2*.ᙊ§AdvCircle,-.¨Point,3¨ᙠᙊᑁa©ᙊ᜜ᓽ¨ᙊḄᐵᙊᑁᙊ᜜ᫀ3S«¬.ᫀḄḄᑖ

1232.4**1®ᑏC++°ᡂB±ud1-.Pointᐸ'ឋᒹ´¨Ḅᙶ᪗¶3¨q·¸ḄEF¹2-.ᙊ§ᐸ'ឋᒹ´ᙊº»¼3½¾.ᙊ§UᵨᡝÀᐭᙊºᙶ᪗»¼ᑨÃ.ᙊᔲ¡Ä?ÀÅÆ஺*2?ÇÈ-.ÉVRectangleḄʧᐸ'ឋVʧḄ˱Ì9ÍÎÌ.¨Ḅᙶ᪗᪷&ᙶ᪗d3ʧḄ☢*3-.Treeᨵᡂᕒages᪛Ñᡂᕒ(ᦪgrowintyearsagesÒÎyears,ageÓUtreeḄagesḄÔ஺

1243Ḅ᪀⌼᪆᪀ØÙ½¾-.gÚÚ◤⌕*ÜÝÞᓄḄà*᝞ᦪ&ᡂᕒâÔ஺ãäḄᦪ&ᡂᕒKdᙠgÞᓄḄ஺Vjåæ1.X⚪C++®èᘤ¶j᪀⌼(ᦪ(constructor)ᩭᜐᳮḄÞᓄ஺᪀⌼(ᦪ-íᱯîḄᡂᕒ(ᦪ9ᐸïᡂᕒ(ᦪKfK◤⌕ᵨᡝᩭðᵨñòᙠ¾gCó᡻M஺3.1᪀⌼᪆᪀(ᦪ1᪀⌼(ᦪ᪆᪀(ᦪḄᭆöᨵᐵ᪀⌼(ᦪ1᪀⌼(ᦪ÷ðᵨ1)C++7ḄAB9É¡fḄᱯîᡂᕒ(ᦪ1í9É¡fḄᡂᕒ(ᦪøù᪀⌼(ᦪ¹2)᪀⌼(ᦪᙠgABᨵúᦪ¹3)ûᨵüýþÿḄ஺2᪀⌼ᦪḄᵨᵨC++ᘤᵨ᪀⌼ᦪᵨᙠᑣ◤⌕ᵨ᪀⌼ᦪᨵᐵ᪆᪀ᦪ3)᪆᪀ᦪ"#$ᵨ1)C++%Ḅ&'"#(ᱯ*Ḅᡂᕒᦪ-ᳮ/012(ᱯ*Ḅᡂᕒᦪ34᪆᪀ᦪ56~ClassName()2)᪆᪀ᦪ7ᨵ8ᦪ97ᨵ:;<=Ḅ

1253᪆᪀ᦪᙠ/0├?@Aᵨ4᪆᪀ᦪᵨBᑴC++ᘤᵨDṹFGdm01_᪀⌼ᦪḄHẠ,cpp2C++ᘤ᪀⌼᪆᪀JᫀPK/0LGMNᓄJᫀPQ᪀⌼ᦪR᪆᪀ᦪḄST☢ᔣ/0ḄWXYZ[\%ᩭ1Bஹ_`ᔆ@1Y᪵Ḅ஺[\%cᙠḄ/0dYAMNᓄefghḄiMNj᝱Y/0lmcᙠḄ(j᝱ḄlnJᫀop(dqr(publicḄinitializeᦪi/0steuᓽᵨinitializeᦪwxMNᓄ஺yz{ᑖ᪆1initialize}Y(lnḄᦪ1~LGḄᵨ2ᵫᜫḄST1/07ᨵMNᓄ1Y"Ḅ7ᨵMNᓄḄ/01ᐸᑁᡂᕒḄY"Ḅ3ᐰ⚪஻o/0◤⌕MNᓄᨵ᪵ḄMNᓄJᫀ#include"iostream"usingnamespacestd;/*Wὃo◤⌕MNᓄ☢ᔣ/0WXᩭ[\1Bஹ_ஹᵯ¡¢1`ᔆ@ᨵMNᓄ£᪵wxMNᓄ?

126Jᫀ1:LGᵨJ6z{᧕¦ஹ§¨iLGᵨinit,ᐰ⚪7classTest21(public:intm;intgetM()const{returnm;}voidsetM(intval){m=val;}intn;intgetN()const{returnn;}voidsetN(intval){n=val;}public:intinit(intm,intn)(this->m=m;this->n=n;return0;)protected:private:

127);intmain()(intrv=0;Test21tl;஻©8᪀⌼ᦪḄᵨJ6Test2112;//tl.init(100,200);//t2.init(300,400);cout«tl.getM()«""«tl.getN()«endl;cout«t2.getM()«""«t2.getN()«endl;஻"#/0ᦪª@17ᨵBwxLGMNᓄTest21arr[3];//Testarr_2[3]={Test(l,3),Test஺1Test()};system("pause");returnrv;3.2᪀⌼ᦪḄᑖ$ᵨC++ᘤ«¬ᕒqrḄ/0MNᓄJᫀ1®¯ᜧ±g᫏³஺஻ᨵ8ᦪ᪀⌼ᦪḄ´µᵨJ6

128classTest(private:inta;intb;public:஻©8ᦪ᪀⌼ᦪTest()(>}஻¶8ᦪḄ᪀⌼ᦪTest(inta,intb)(>}஻·᪀⌼ᦪTest(constTest&obj))

129public:voidinit(int__aint_b)?(a=_a;b=_b;)}i1©8ᦪ᪀⌼ᦪᵨJ6Testtl,t2;2ᨵ8᪀⌼ᦪᨵ8᪀⌼ᦪḄ´µᵨJ6஻ᨵ8ᦪ᪀⌼ᦪḄ´µᵨJ6classTests{private:inta;public:஻¶8ᦪḄ᪀⌼ᦪTest5(inta)printf("

130a:%d",a);

131)Test5(inta,intb)(printf("

132a:%db:%d",a,b);)public:)iintmain55(){Teststl(10);஻c++ᘤ¸¹ᵨᨵ8᪀⌼ᦪº»6Test5t2=(20,10);஻c++ᘤ¸¹ᵨᨵ8᪀⌼ᦪ¼»6Test5t3=Test5(30);஻¬ᕒᵨ᪀⌼ᦪ¡[½(/0¾¿ᵨ᪀⌼᪀⌼ᦪ6system("pause")ireturn0;)3ÀÁ᪀⌼ᦪᵨ@B·᪀⌼ᦪḄµᵨÃÄ(ᵨ@B)Ç1RÇ2(ᵨÃÄ#include"iostream"usingnamespacestd;

133classAA(public:AA()஻©8᪀⌼ᦪ¸¹᪀⌼ᦪ(cout<<"ᡃY᪀⌼ᦪ1Aᵨ½"<

134",a);)

135protected:private:inta;};஻ᓫÎÏt(ÐÑvoidObjPlay01()(AAal;஻"#஻·᪀⌼ᦪḄÇ(ÒᵨÃÄ஻ᵨ/01MNᓄ/02AAa2=al;஻"#ÓMNᓄ஻MNᓄ6a2=al;஻ᵨalᩭ=»«a2ᘤ«ᡃÕqrḄÖcopyÇ×(ÒᵨÃÄ஻ᓫÎÏt(ÐÑvoidObjPlay02()(AAal(10);஻"#஻·᪀⌼ᦪḄÇ(ÒᵨÃÄ஻ᵨ/01MNᓄ/02

136AAa2(al);஻"#ÓMNᓄ஻º»6஻a2=al;஻ᵨalᩭ=»«a2ᘤ«ᡃÕqrḄÖcopya2.getA();)஻ØÙMNᓄÚÛR¼»ÚÛYÜ(ÝḄᭆßÇ3(ᵨÃÄ#include"iostream"usingnamespacestd;classLocation(public:Location(intxx=0,intyy=0)(X=xx;Y=yy;cout«"ConstructorObject.

137";)Location(constLocation&p)஻àᑴ᪀⌼ᦪ(X=p.X;Y=p.Y;cout«"Copy_constructorcalled."«endl;}~Location()

138cout«X««Y«"Objectdestroyed."«endl;)intGetX(){returnX;}intGetY(){returnY;}private:intX,Y;}i//alt+f8᣸᱐voidf(Locationp)(cout«"Funtion:"«p.GetX()««p,GetY()«endl;}voidmainobjplay()(LocationA(1,2);஻ã8Y(ᐗå1ᦪᵨ1᡻xç8MNᓄã8f(A);)voidmain()(mainobjplayO;system("pause");

139Ç4(ᵨÃÄÇÂ(ÒᵨÃÄftindude"iostream"usingnamespacestd;classLocation(public:Location(intxx=0,intyy=0)(X=xx;Y=yy;cout«"ConstructorObject.

140";)Location(constLocation&p)஻àᑴ᪀⌼ᦪ{X=p.X;Y=p.Y;cout«"Copy_constructorcalled."«endl;}-Location஺(cout«X«""«Y«"Objectdestroyed."«endl;z)intGetX(){returnX;}intGetY(){returnY;}private:intX,Y;)i//alt+f8᣸᱐

141voidf(Locationp)(cout«"Funtion:"«p.GetX()««p.GetY()«endl;}Locationg()(LocationA(l,2);returnA;)஻/0MNᓄÚÛR=¼»ÚÛYÜ(ÝḄᭆß஻èé/0ḄêRᶇ1ᐵìí1<=@᝞;¿voidmainobjplayO(஻ï<=Ḅèé/01ð«Ê᜜(ÝḄ/01èé/0A᪆᪀//LocationB;஻B=g();஻ᵨèé/0·«B/01ᯠeèé/0᪆᪀஻ï<=Ḅèé/01ᩭMNᓄÊ᜜(ÝḄ/01èé/0¾¿òᡂóḄ/0LocationB=g();cout<<"õö÷ᙢùúû"üendl;

142voidmain()(mainobjplay();system("pause");}᪘ᵨa¤¥¦[FG§objplay3()஻ᵨḆª«¬ᓄmJ&c++®ᘤ°±²/ᡂ■.//(ᢄ·)¹ºᡂᨵn[Locationm-g();printfL»¼½ᢄ·>¾᪆᪀Á

143").cout<<».GetX0<

144").cout<

14522᪀⌼ᦪC++ᘤ3./0ᦪ᪀⌼ᦪ32,4Ḅ5᪀⌼ᦪ6ᓽ82ᨵ0᪀⌼ᦪᡈ/0᪀⌼ᦪ:C++ᘤ3./0᪀⌼ᦪ4᪀⌼ᦪᡂᕒ!"ᓫ;#<=8>⌕@ᑏ2᪀⌼ᦪBC@DEᵨ஺᪀⌼᪆᪀▤Iឋ<=1᪀⌼ᦪKC++ᵨLMNᓄPQR᝱ḄᱯUᦪ2᪀⌼ᦪᙠPQWXYZ[&ᵨ3᪀⌼ᦪ1\]ᡂᕒᦪ^⍳`ab(ᑣ4᪀⌼ᦪKPQcdMNᓄḄa⌕ef5D⌕Ḅ᎛DEhiᑏ᪀⌼ᦪ========k1PQḄMNᓄlm2noᫀq஺3.4r1s>$ᑴ᪀⌼ᦪuvmᡂPQḄᦪwᡂᕒ#ᓫḄ$ᑴ>PQḄᦪwyzKᵫᢣ┐ᢣ~Ḅᚮ$ᑴ᪀⌼ᦪᢣ┐#$ᑴ1s⚪1ᑖ᪆rsQḄ2sC++Ḅ~copy᪀⌼ᦪ~ab=3ᵨᘤḄscopyclassName

146public:Name(constchar*pname)(size=strlen(pname);pName=(char*)malloc(size+1);strcpy(pName,pname);)Name(Name&obj)(஻ᵨobjᩭMNᓄYpName=(char*)malloc(obj.size+1);strcpy(pName,obj.pName);size=obj.size;}~Name(){cout<<"N᪆᪀"<

147)voidoperator=(Name&obj3)(if(pName!=NULL)(free(pName);pName=NULL;size=0;)cout<<"ᨵᨵ&ᵨᡃ஺ooo"«endl;஻ᵨobj3ᩭ=YpName=(char*)malloc(obj3.size+1);strcpy(pName,obj3.pName);size=obj3.size;)protected:private:char*pName;intsize;)

148஻PQḄMNᓄ1PQK3¡Ḅᭆ£voidplayObj()(Nameobjl("objl.....");Nameobj2=objl;//obj2WX¤MNᓄNameobj3("obj3...");஻ab¥obj2=obj3;஻cout<<”§¨஺஺05000"«endl;)voidmain61()(playObj();system("pause");

149᪘ᚮvoidobjplaymain0(Nameobj1("abcdefg");//Nameobj2ãobj1;஻C++®ᘤfgḄäåḄcopy᪀⌼1ᦪçèéNameobj3(zobj3z/);obj3=objl;//C++®ᘤfgḄêëìíçèé)

1503.5ÆPQ᪀⌼1᪆᪀1PQMNᓄᑡ⊤1)PQMNᓄᑡ⊤1.DEÉ᪵Ë8᝞ÍᡃÎᨵᡂᕒÏÐÑKᡈὅK=᪀ÓÔÉᡂᕒÏ>ᨵÕ0ᦪḄ᪀⌼ᦪᨵ᪀⌼ᦪ஺É⌕PÉᡂᕒMNᓄÖDE&ᵨÉᡂᕒḄÕ0ᦪḄ᪀⌼ᦪ᝞ÍᨵMNᓄᑡ⊤BC×Ø/mᡂÙÚÖ.Û┯஺2ஹᡂᕒÞᨵconstß⛲DEᙠPQMNᓄḄ᎛áconstintm;#ᡂᕒâᨵconstPQᡈὅKãᵨ×ÎäDE⌕]åᡂᕒMNᓄᑡ⊤MNᓄÉæPQ⌕ᙠçèéêëMNᓄÓᙠ᪀⌼ᦪËḄKP×ÎḄ;#É᪵K3[ᐕíḄ஺2)C++MNᓄᑡ⊤Pᡂᕒ!"MNᓄî(ᑣConstructor::Contructor():ml(vl),m2(vl,v2),m3(v3)(//someotherassignmentoperation}3)ï4ᭆ£MNᓄ8[MNᓄḄPQcᙠWX;#8[;#ḄPQðñòᙠ

1514ï48ᡂᕒ!"ḄMNᓄóôçèḄóõᐵôᙠMNᓄᑡ⊤Ḅó/ᐵMNᓄᑡ⊤ᐜL᪀⌼ᦪḄᦪø᡻1C++2MNᓄᑡ⊤Pᡂᕒ!"MNᓄ2ᵨMNᓄᑡ⊤81.DEÉ᪵Ë8᝞ÍᡃÎᨵᡂᕒÏÐÑKᡈὅK=᪀ÓÔÉᡂᕒÏ>ᨵÕ0ᦪḄ᪀⌼ᦪÓᨵ᪀⌼ᦪÉ⌕PÉᡂᕒMNᓄÖDE&ᵨÉᡂᕒḄÕ0ᦪḄ᪀⌼ᦪ᝞ÍᨵMNᓄᑡ⊤BC×Ø/mᡂÙÚÖ.Û┯஺2^ᡂᕒÞᨵconstß⛲DEᙠPQMNᓄḄ᎛áconstintm;#ᡂᕒâᨵconstPQᡈὅKãᵨ×ÎäDE⌕]åᡂᕒMNᓄᑡ⊤MNᓄÉæPQ⌕ᙠçèéêëMNᓄÓᙠ᪀⌼ᦪËḄKP×ÎḄ;#É᪵K3[ᐕíḄ஺7஻<=᪀⌼1᪆᪀Ḅ&ᵨó/include"iostream"usingnamespacestd;

152classABC(public:ABC(inta,intb,intc){this->a=a;this->b=b;this->c=c;printf(”a:%d,b:%d,c:%d

153"a,b,c);zprintf("ABCconstruct..

154");)úABC()(printf(”a:%d,b:%d,c:%d

155",a,b,c);printf(“úABC()..

156");)protected:private:inta;intb;intc;)

157classMyD(public:MyD():abcl(l,2,3),abc2(456),m(100)//MyD()(cout«"MyD()"«endl;)úMyD()(cout«"~MyD()"«endl;)protected:private:ABCabcl;஻c++ᘤ3ûII⍝᝞-᪀⌼abclABCabc2;constintm;)intrun()

158MyDmyD;return0;)intmain__dem03()(run();system("pause");return0;3.6᪀⌼ᦪ1᪆᪀ᦪḄ&ᵨóẆ+᪀⌼ᦪô᪆᪀ᦪḄ&ᵨó1ᨵᡂᕒ!"KᐸÏḄPQ✌ᐜ&ᵨᡂᕒ!"Ḅ᪀⌼ᦪ&ᵨóôçèóõ¡é&ᵨYÑḄ᪀⌼ᦪ2᪆᪀ᦪḄ&ᵨóôPÿḄ᪀⌼ᦪᵨ3.7᪀⌼ᦪ᪆᪀ᦪᔠᡠᩭ1᪀⌼᪆ᔠdemolO—᪀⌼᪆᪀ᓄ.cpp!"#$%&ᑖ᪆()*+,᪀ᦪḄᵨ

1592-./0ᓄdemolO—᪀⌼᪆᪀ᓄ.cpp1-./012ᕜ42-./0Ḅ5ᶇ3-./0ᓄ3᪀⌼7ᵨ᪀⌼demoll_-./0ᓄ.cpp᪀⌼ᦪ7ᵨ᪀⌼ᦪ89:;<Ḅ=>஺3.8/0Ḅ@᝱BCDE1newdeleteFGHI1ᙠKLMN(7OO◤⌕@᝱ᙢᑖST├ᑁWXYZ᝞/@᝱\⊤7^Ḅ_ᐭaᑤ◀஺ᙠCHd78ᑭᵨfᦪmallocfreeᩭᑖST├ᑁWXYḄ஺C++ghijklmnojḄpqrnewdeleteᩭstmallocfreeᦪ஺)*unewdelete8pqrv8ᦪwx᡻=ᦔ᳛|஺2}ᯠ>iaCHdC++ᶇmallocfreeᦪBᵨᡝvᵨmallocfreeᦪmᵨnewdeletepqr஺newpqrḄZunewint;஻M9:WE᦮ᦪḄWXY9:ᢣᔣWXYḄᙢᙬ!ᓽᢣ┐$newintlOO;஻M9:WE᦮ᦪḄXYᢣ᦮ᦪḄ,>100,9:ᢣᔣWXYḄᙢᙬnewchar[10];஻M9:WErᦪ!ᒹ10:ᐗ$ḄXY✌ᐗḄᙢᙬnewintমভ஻M9:WE¡᦮¢ᦪ!ᜧ¤>5*4ḄXY✌ᐗḄᙢᙬfloat*p=newfloat3.14159;஻M9:WEᓫ¦§ᦪḄXYᢣ¨ᦪḄ,>//3.14159,©ḄXYḄᙢᙬ+ªᢣ┐«¬p3$newdeletepqrᵨḄ9®¯°>:

160>new%{᝱ᑖðᚮᑁòóᵨô)Iᢣ┐«¬=new´¢!⁻¬$õᢣ┐«¬=new´¢¶⊤·■¹;ᵨ.•¹ᚮᑖðFᙽ“!"”ᜧùḄòúûüMN✌ᙢᙬᐸ:“,'ᓄḕᦪᢣ-deleteᑖ"Ḅᑁ%&'(ᵨ*+,deleteᢣ┐;deleteᢣ┐;ᐸ.•“ᢣ┐0”2345new67Ḅᢣ┐ᵨnewᑖSᦪXY»voᢣ,஺᝞¼ᵫ¾ᑁWv¿ÀÁwmÂIÃOᑖSXYᑣnewÅ9:Xᢣ┐NULL,ᵨᡝÆÇ᪷Éᢣ┐Ḅ,ᑨËᑖSXY8ᔲᡂn஺4ÎᵨÏZint*pl=newint;char*p2=newchar;float*p3=newfloat;int*p4=newint[4];deletepl;deletep2;deletep3;delete[]p4;2´/0Ḅ@᝱BCDEᵨ´.ÐḄ/08☟᝱Ḅᙠ(p=(7/0ᡠᓰḄXY8voÓ»D

161EḄ஺ᨵ»ÕÖ×Øᙠ◤⌕ᵨᑮ/0»ÚBC/0ᙠv◤⌕ᵨ/0»ÛT├ÜDEÜᡠᓰḄᑁWXYÇhÝḄᦪÉᵨ஺Þ᪵Æg|ᑁWXYḄᑭᵨ᳛஺C++7ÆÇᵨnewpqr@᝱BC/0ᵨdeletepqrT├/0à᝞uBox*pt;஻Ð9:ᢣᔣBox´/0Ḅᢣ┐«¬ptpt=newBox;஻ᙠpt7WEiáB/0Ḅâᙢᙬᙠ(7ÛÆÇptãäÞ:áBḄ/0஺᝞cout«pt->height;஻åæ/0Ḅheightᡂᕒcout«pt->volume();஻ᵨ/0ḄvolumeᦪèqåæéêC++ëᐕíᙠ᡻=new»/áBCḄ/0î=âᓄ஺᝞Box*pt=newBox(12,15,18);ÞïᑏI8ñ☢ó:Hô(Ðᢣ┐«¬ᵨnewBCá/0)ᔠ>9:Hôᢣ,஺Þ᪵÷¦ø஺á/07Ḅheight,widthlengthᑖÝùú,12,15,18஺ᵨ/0ûÆÇ/0.üÆÇᢣ┐஺ᙠ᡻=newpq»᝞¼ᑁW¬v¿ÂIMᡠ◤ḄᑁWXYýþᜧÿᦪC++new0ᢣ┐஺⌕ᔲ0,ᑨᑖᑁᔲᡂ஺ANSIC++᪗!"#$ᙠ᡻'new#(ᦑ*+$"-#""./”$ᵨᡝ᪷4./5'ᨵᐵᜐᳮ஺:C++᪗!;ᯠᐕ>ᙠ#(newᦑ*+0ᢣ┐஺?@$ABḄDnewᦑ*ḄᜐᳮEFABḄ஺ᙠAG◤⌕ᵨᵫnewJKḄDL+$MᵨdeleteNOPQMRS஺᝞deletept;஻RSptᢣᔣḄᑁWXYZ├\ptᢣᔣḄDL஺^_`aAbGᵨcDL஺᝞dᵨᢣ┐efptᐜ_ᢣᔣABḄh᝱DL$jklᢣ┐efḄ?@ᢣᔣ$Mmᑤ┯\DL஺ᙠ᡻'deleteNOP+$ᙠRSᑁWXp@$qhrᵨ᪆᪀uᦪ$vᡂᨵᐵᗐ_xᳮyz஺3`{|//Imallocfreeuᦪcᐵ}~//newdeletezPC++Ḅᐵ}~

162112.newᙠᚮᑖᑁdelete஻ᑖẠஹᑖᦪஹᑖDL//3newmallocᐭᑖ᪆ᵨஹ.BmallocArᵨḄ᪀⌼uᦪFreeArᵨḄ᪆᪀uᦪ4☟᝱ᡂᕒefᡂᕒuᦪὃef$ᨵឋ஺ᨵᨵឋ$ᡠᨵDLᨵ¡4.1☟᝱ᡂᕒef1¢£☟᝱ᡂᕒef>ᐵ}~staticMᵨ¥¦§Ḅᡂᕒ$☟᝱ᡂᕒ"¨\BDLḄᐳª«ᑴ>Ḅᡂᕒ¦§static+$Y®ᨵ¯°DL±²J$YDLᐳªYstaticᡂᕒ>☟᝱ᡂᕒ³´¥$µADLᡂᕒ

163classX{charch;staticints;........}:intX::s=0;Xa.b.c.d;b,ch\c.chstaticints;______________d.ch¶᝞#includeusingnamespacestd;classcounter(staticintnum;஻¸§¹¢£☟᝱ᦪ4ᡂᕒpublic:voidsetnum(inti){num=i;}஻ᡂᕒuᦪº»☟᝱ᦪ4ᡂᕒvoidshownum(){cout«num«'\t';})¼intcounter::num=0;஻¸§¹¢£☟᝱ᦪ4ᡂᕒvoidmain(){countera,b;a.shownum();஻rᵨᡂᕒuᦪº»½ᨵ☟᝱ᦪ4ᡂᕒb.shownum();a.setnum(lO);

164a.shownum();b.shownum();¾dM¿#$º»ḄB☟᝱ᦪ4ᡂᕒ2)ᵨ☟᝱ᡂᕒef//514ᵨᨵ☟᝱ᦪ#ᡂᕒ#includeclasscounter{public:counter(inta){mem=a;}intmem;஻ᨵᦪ#ᡂᕒstaticintSmem;஻ᨵ☟᝱ᦪ#ᡂᕒ)¼intcounter::Smem=1;஻'()*1voidmain(){counterc(5);inti;for(i=0;i<5;i++){counter::Smem+=i;cout«counter::Smem«'\t';஻º»☟᝱ᡂᕒefEF2

165)cout«endl;cout«"c.Smem="<☟᝱ᡂᕒuᦪᦪÂMᐵ}~static>☟᝱ᡂᕒuᦪ"¨AÃÄ¥ᦪ4᪀ḄᐳBz$µᨵthisᢣ┐>ᙠ᜜rᵨ☟᝱ᡂᕒuᦪᵨ"Æ:"z▲¢É$ᡈËÌDLrᵨ2ᫀ¶᝞classX{intDatMem;public:staticvoidStaFun(inti.X*ptr):);voidX::StaFun(inti.X*ptr)(ptr->DatMem=i://-.}3ᶧл⚪☟᝱ᡂᕒuᦪÒ$AbᵨÓËef஺஻☟᝱ᡂᕒef¥᦮Ḅ$ᑖAxÕ$ÖᐹØDLḄឋ஺

166I"static8⛲Ḅ0:;<ᡠᨵḄ?ᐳAᵨ஺luoidmain()HBBb1;BBb2;cout«b2.getC()«endl;;b1.setC(100);cout<

167staticᡂᕒᦪcnonstaticstatic<ᡂᕒᦪnonstaticvirtual5.10Ạ23C++Ḅclass4☢ᔣ7ᳮ9:;<=>?ឋ@ᦪAB@CᙠDEᵨGHIJKḄ஺4LMNḄOPQRSᯠᵫᦪVWṹV᪀ᡂ஺C++Z[ᘤ᝞^_ᡂ☢ᔣ7ᳮ9ᑮLMNQRḄaᓄcᣚef+C++Z[ᘤg᝞^hᳮஹ7ஹ7ḄᐵiᐹkḄ&+ᐹk7lᵨḄABmC++Z[ᘤg᝞^nᑖgmpᐹkḄlᵨqpABmcrὃDtQRuvinclude"iostream"usingnamespacestd;classClpublic:inti;//4intj;//4intk;//4protected:private:

168)-//12classC2(public:inti;intj;intk;staticintm;//4public:intgetK()const{returnk;}//4voidsetK(intval){k=val;}//4protected:private:}-//241612(w┑Ḅy7)structSI(inti;intj;intk;};//

169structS2inti;intj;intk;staticintm;-//intmain()(printf("cl:%d

170sizeof(Cl));printf("c2:%d

171",sizeof(C2));printf("sl:%d

172"sizeof(Sl));zprintf("s2:%d\rT,sizeof(S2));system("pause");5.2Z[ᘤ7?ឋABḄᜐᳮNᑴ}☢ḄᫀᡃḄ:+1)C++7Ḅᡂᕒ=>ᡂᕒᦪgᑖḄᡂᕒ=>+ᡂᕒ=>+G7struct=>ᨵḄᑁ⁚7A

173☟᝱ᡂᕒ=>+Gᐰᦪnᡂᕒᦪ+GWṹV஺⚪:ᩭ+7ᐳᵨDᙽWṹcWṹg᝞^nᑖᐹk7Ḅmcᣚef&+intgetK()const{returnk;},Wṹg᝞^nᑖ,ᐹkobjlஹobj2>obj37Ḅkc2)C++Z[ᘤ7ᡂᕒᦪḄᑁᜐᳮclassTeststructTest<(private:intml;intml;>public:uoidTest_initialize(Test»pThis,inti)Test(inti)<nI-i;ml■1;>intTest_getI(Test*pThis)intgetI()<»I;returnnl;}>uoidTest_Print()staticuoidPrint(){

174");printFC'ThisisclassTest-Xn**);>>>Testa;Testa(10);Test_initialize(&a,10);a.getIO;Test_getI(&a);Test::Print();Test_Print();¡¢rὃ&:£Ḅ¤u¥5.3¤u1ஹC++7Ḅᡂᕒ=>ᡂᕒᦪgᑖḄ஺c¦§Ḅᑁ¨n©ªᯠᨵᦔ¥2ஹC++Ḅᡂᕒᦪ¬◚ᒹ¯Dpᢣᔣ±²7Ḅthisᢣ┐஺3ஹ☟᝱ᡂᕒᦪஹᡂᕒ=>?G☟᝱ᡂᕒᦪᡂᕒᦪḄn´

175☟᝱ᡂᕒᦪyᒹ¯ᢣᔣᐹk7Ḅᢣ┐ᡂᕒᦪᒹ¯Dpᢣᔣᐹk7Ḅᢣ┐5.4thisᢣ┐ᡂᕒᦪ◚¯U”ᢣ┐=include஻ᴉ-5classSimple"µlᵨ7Ḅᙢᙬ{ialxy::voidprintXY(){cout«xvoidsetXY(Simple*constthis,inta,iptb){this->x=a;this->y=b;}};voidniain(){Simpleobjl.obj2.objifobjl.x[1objl.yobjl.setXY(10.15XgbjjysetXY(10.15,&objl);obj1.printXY():obj2.xobj2.yobj+.setXY(20.2"ஹ:obj2.printXYO:obj3.xobj3.yobj3.setXY(30,35);obj3.printXYO-¸1+¹ᡂᕒᦪḄº»Ḅ?ឋ¼thisᢣ┐ᩭ½¾஺¸2+Ḅᡂᕒᦪconst¿⛲const¿⛲ḄgÁ5.5ᐰᦪPKᡂᕒᦪ1ஹÂᐰᦪaᓄᡂᡂᕒᦪthisᢣ┐◚ÃÄÅÆᦪTestadd(Test&tl,Test&t2)==ÇTestadd(Test&t2)2ஹÂᡂᕒᦪaᣚᡂᐰᦪDp»ᦪvoidprintAB()ÈÈÈÇvoidprintAB(Test*pthis)

1763ஹᦪÉÊᐗÌÉÊÍᵨTest&add(Test&t2)//*this஻ᦪÉÊÍᵨ(this->a=this->a+t2.getA();this->b=this->b+t2.getB();return*this;஻*ÅÆÐthisᢣ┐ÊᑮᐗÌÑ᝱}Testadd2(Test&t2)஻*this஻ᦪÉÊᐗÌ(//t3g=>Testt3(this->a+t2.getA(),this->b+t2.getB());returnt3;)

1776Òᐗ6.1ÒᐗᦪCDEFGHIJKLMNᐵpublic:voidMemberFun(int););voidFriendFun(A*ptr.intx){ptr->i=x:};voidA::MemberFun(intx)classA{private:voidFriendFun(4*ptr,intx)x;};voidA::MemberFun(intx){i=x;};᝞

178classAl(public:Al()(al=100;a2=200;}intgetAl()(returnthis->al;)஻ÓÔDpÒᐗᦪfriendvoidsetAl(Al*p,intal);஻qpᦪgqpḄÕÖÒprotected:private:intal;inta2;)-voidsetAl(Al*p,intal)p->al=al;

179voidmain()(Almyal;cout«myal.getAl()«endl;setAl(&myal,300);஻Òᐗᦪ¿ᦋAḄØᨵ?ឋcout«myal.getAl()«endl;system("pause");-includeᵨ2ᕒ3ᦪ456789Ḅ;<^includeclassPoint{public:Point(doublexi.doublevi){X=xi:Y=vi:}doubleGetXQ{returnX:}doubleGetY(){returnY:}ᦪDistancefrienddoubleDistance(Point&a,Poj,&b);private:doubleX.Y:}:doubleDistance(Point&a.Point&b){doubledx=a.X-b.X;doubledv=a.Y-b.Y;returnsgrt(dx*dx+dy*dy);}voidmain(){Pointpl(3Q5.0),p2(4.06.0);?doubled=Distance(pl.p2):cout«"Thisdistanceisn«d«end1;

1806.2ÒᐗÙ¹BgAḄÒᕒᑣBḄᡠᨵᡂᕒᦪ¬gAḄÒᕒᦪÙÒᕒÜÝLÞD(7ᦪÅÆᡈà⌴âãḄäå=>2ᕒ?=includeclassA{friendclassB;PAḄQᐔpublic:voidDisplayO{cout«x«endl:};private:___intx;/ST<ᡂᕒVc/JKA<ḄXᨵᦪYᡂᕒclassB/________________________{public:/voidSet(inti){Aobject.x=H}voidDisplay0{Aobiect.Display():}private:AAobiect:BZᨵ5A,ABḄ[:ឋ)-voidmain(){BBobject:Bobiect.Set(100):Bobiect.Displav0:}7æᓄçè1staticᐵéæᓄçè⚪Aëᖪíî├D(ðᱥ஺ðᱥòóᓬ:õöÞᓫøᔜöḄú>yD᪵üý,ᖪí◤⌕Ḅ஺ᙠᵨC++ᖪᱥᓬḄ஺#include"iostream"usingnamespacestd;

181classGoodspublic:Goods(intw){weight=w;total_weight+=w;}Goods(){total_weight-=weight;}intWeight(){returnweight;};staticintTotalWeight(){returntotal_weight;}Goods*next;private:intweight;staticinttotal_weight;}intGoods::total_weight=0;஻!ᢣ┐voidpurchase(Goods*&f,Goods*&r,intw)(Goods*p=newGoods(w);p->next=NULL;if(f==NULL)f=r=p;else{r->next=p;r=r->next;}஻!ᢣ┐$%ᡈ'()*ᡂ!()

182voidsale(Goods*&f,Goods*&r)(if(f==NULL){cout«"Noanygoods!

183";return;}Goods*q=f;f=f->next;deleteq;cout«"saled.

184";}voidmain()(Goods*front=NULL,*rear=NULL;intw;intchoice;do{cout«"Pleasechoice:

185";cout«"Keyin1ispurchase,

186Keyin2issale,

187Keyin0isover.

188";cin»choice;switch(choice)//-.⌱0(case1://1ᐭ1,13ᱥ{cout«"Inputweight:";cin»w;purchase(front,rear,w);//4⊤6ᐭ17()break;)

189case2://1ᐭ2,813ᱥ{sale(front,rear);break;}//4⊤ᜮᑤ◀17()case0:break;//1ᐭ0,(<)cout«"Nowtotalweightis:"«Goods::TotalWeight()«endl;}while(choice);2ᦪ>?@A᪗CDEF▭H⚪JKL᪀⌼Oᦪஹcopy᪀⌼OᦪQJR-.STUVᜓᦪ>?ḄXYinclude"iostream'1include"Array.h"usingnamespacestd;intmain()(Arrayal(10);for(inti=0;i

190)for(inti=0;i

191Ji,al.getData(i));}Arraya2=al;for(inti=0;i

192"i,a2.getData(i));/)system("pause");return0;ᦪ>?Ḅᜮᦻ[#ifndefMYARRAYH#define_MYARRAY_H.classArray

193private:intmLength;int*mSpace;public:Array(intlength);Array(constArray&obj);intlength();voidsetData(intindex,intvalue);intgetData(intindex);[Array஺)#endif3](>?_`ᵨᐵ1bclasscd஺?eᦪfᡂᕒᡂᕒOᦪḄ@A஺?ḄFhiRjk஺>(᪀?lᵨᐵ1bstructcdJeᵫno?lᦪf>ᡂḄᦪf?l஺>?ᡂᕒᵫprivate,protected,publicEcpHᱯឋ஺publicᡂᕒsiRtu஺>᪀⌼Oᦪᙠvwxyᓄjk{|}~ᵨ஺᪆᪀Oᦪᑣᙠjk.ᵨ(<{|}~ᵨ஺>T᪀⌼Oᦪᑴ᪀⌼OᦪvwjkḄnoxyᓄ஺>☟᝱ᡂᕒe!?ḄᡂᕒJo?jkḄᐳᑴ஺ᕒᵨᐵ1bfriendᕒej?-.Ḅ஺7?Ḅᕒp

194H?ᔜឋḄᡂᕒ஺⊤e⌕Ḅ}᝱ᦪf(᪀Jᙠ¢£¤¥{vwᡈ¦§ᦪfᐗ©஺8¤ªST8.1ᭆ¬®e¤ªST¤ªST¯°ᵨᡝ|cdḄᦪf²³´Ḅµ.h᝞ml=Madd(ml,m?);஻@ᵨ3ᦪ456AB▣Ḅᡠ¸TJ¹e'º»'Ḅ¼d஺OᦪT¹ej7½ᨵḄOᦪº»'Ḅ¼d,¯ÀF'ÁÂJÃÄJ7OᦪŹᵨᩭÇ⊤noÁÂḄOᦪJȹe"ÅÊᵨ”஺¤ªSÈT஺F▭ÌJᡃÎÏÐᙠnÑnÒÀÓ¯ᵨ¤ªST஺h᝞JᜧÕÖÏ×ØᵨÙÚ¤ªSj᦮ᦪஹᓫÝÞᦪßÝÞᦪ¥ÙÚ¤ªJ᝞5+8,5.8+3.67QJᐸFáªj᦮ᦪஹᓫÝÞᦪßÝÞᦪḄÙÚ-.â¢eãnäoḄJåᵫC++ÏÐj¤ªS”+"¥TJᡠ¹Â〉ᵨint,float,double?lḄ¤ª஺

195è᝞"<<"eC++ḄꤪÓḄê%¤ªSëì%íJåᙠî-.Óèeïðjkcoutñᔠ¯ᵨḄð6ᐭ¤ªSJ">>"Èeê%¤ªSëó%íJåᙠîᐭ-.Óèeïðjkcinñᔠ¯ᵨḄðô¤ªS஺õ¹e¤ªSToperatoroverloading,C++ö÷j"<<"">>"¥TJᵨᡝᙠnoḄøᔠ$¯ᵨùÎ{J.ᵨenoḄ஺j"<<"">>"ḄTᜐᳮeüᙠᜮᦻ[streamÓḄ஺ÃÄJ᝞ý⌕ᙠ¢£Óᵨ"<<"">>".ð6ᐭ¤ªSðô¤ªSJþÿᙠᦻᙽᒹᜮᦻstreamᯠᒹ"usingnamespacestd"஺ᙠ⌕Ḅ⚪ᵨᡝᔲ᪷!Ḅ◤⌕#C++$%&Ḅ'()*+,-./0123Ḅ4.56789ᵨ஺:'(),-ᐭ<ᢈ>?@1ABCDᵨ'(),-EᑴᵨGᦪIJK//Complexc3=cl+c2;஻MNComplexᵨᡝO4IP.QRᘤ᪷TU⍝᝞X*+YZ஻QRᘤ[%&\7]Eᑴ.^ᵨᡝ!_`ᡂ.O4IPḄYZbc஺஺஺஺஺஻deEᑴf'(),-Eᑴ2'(),-Ḅg7ehᦪclassComplex(public:inta;intb;friendComplexoperator+(Complex&cl,Complex&c2);public:

196Complex(inta=0,intb=0)(this->a=a;this->b=b;)public:voidprintCom()(cout«a«"+"«b«"i"«endl;)private:}j/*ComplexmyAdd(Complex&cl,Complex&c2)(Complextmp(cl.a+c2.acl.b+c2.b);zreturntmp;}*/Complexoperator+(Complex&cl,Complex&c2)

197Complextmp(cl.a+c2.a,cl.b+c2.b);returntmp;)voidmain()(Complexcl(l,2),c2(3,4);//Complexc3=cl+c2;஻ᵨᡝO4IPQRᘤkl^mnoY//ComplexmyAdd(Complex&cl,Complex&c2);//Ipqhᦪ//Complexc3=myAdd(cl,c2);//c3.printCom();//2operator+hᦪ8r//Complexc3=operator+(clc2);z//c3.printCom();஻3+sᣚhᦪ8Complexc3=clc2;஻uὃC++QRᘤ᝞Xwᢝbc),-EᑴḄ(᪷IP)+c3.printCom();

198inta=0,b=0,c;஻{ẠIPC++QRᘤU⍝᝞XYZc=a+b;)//4}ComplexImᡂ~ᨵឋ஻ᐗhᦪḄᵨ//friendComplexoperator+(Complex&cl,Complex&c2);cout«"hello..."«endl;systemCpause*');return;8.2'(),-Ḅ▲ᑴḄ+-*/%A&1J=<>+=-=*=/=%A=&=1=«»»=«==!=<=>=&&II-H---->*6->[]0newdeletenew[]delete[]Ḅ.::.*?:sizeof

199]^_ᦪ`abcḄdefᨵghEi0:Aᦋ0ḄlᐜnAᦋ0Ḅoᔠឋ/ᦋ0ᡠ◤⌕ḄsaᦪAcḄ8.3'(),-Q{Ạt_ᦪ4uᱯwḄᡂᕒ_ᦪᡈQᕒ_ᦪtᡂᕒ_ᦪḄEy*+,::operatorop1ᦪ⊤)Ḅ}X45]^fᨵiᨵᜫi4ᱯ<Ḅ45cK᝞:஻ᐰhᦪ`ᡂ+bc),-Complexoperator+(Complex&cl,Complex&c2)஻Iᡂᕒhᦪ`ᡂ-bc),-Complexoperator-(Complex&c2)

200'(),-Ḅ]lᵨᡂᕒᡈᕒhᦪ,-'()t_ᦪ`]^ᡂᕒ_ᦪᡈQᕒ_ᦪ*ᐵᙠ;ᡂᕒ_ᦪᐹᨵthisᢣ┐Qᕒ_ᦪᨵthisᢣ┐“ᡂᕒ_ᦪQᕒ_ᦪ]^Ḅ(ᵨy஺e⌴ᦪḄ+ṹᵨᔠᵨᡂᕒᡈᕒhᦪ,-'()2-ᐗObjectLopObjectRA]^ᡂᕒ_ᦪd,ObjectL.operatorop(ObjectR)saᦪᵫQbjeQLSTthisᢣ┐⌴.saᦪᵫᦪQbjectR⌴]^Qᕒ_ᦪd,operatorop(ObjectL.ObjectR)saᦪ?ᵫᦪ⌴K᝞1஻q¡Iᡂᕒhᦪ`ᡂ-bc),-஻hᦪ¢£Complexoperator-(Complex&c2)஻hᦪ¤ᵨᑖ᪆

201஻ᵨIᡂᕒhᦪ§-'(),-Complexc4=cl-c2;c4.printComO;//cl.operator-(c2);K᝞2:஻q¡ᐰhᦪl`ᡂ+bc),-஻hᦪ¢£Complexoperator+(Complex&cl,Complex&c2)஻hᦪ¤ᵨᑖ᪆intmainO(Complexcl(1,2),c2(3,4);//Comp1exc31=operator+(cl,c2);Complexc3=cl+c2;c3.printCom();)K᝞3:±ᕒ!²³§*/

202ᵨᡂᕒᡈᕒhᦪ,-'()1.ᐗObjectopᡈopObject;]^ᡂᕒ_ᦪd,Object.operatorop0saᦪᵫObjectSTthisᢣ┐◚¢⌴A]^Qᕒ_ᦪd,operatorop(Object)saᦪᵫᦪ⊤ḄᦪObject¤¥K᝞3஻µ¶++bc)ᵨᐰhᦪ§Complex&operator++(Complex&cl)(cl.a++;cl.b++;returncl;}஻¤ᵨl++C1j஻="◤⌕ᑏ¹bc),-hᦪMºcl.printCom();஻'(),-hᦪ8O4஻✌ᐜ½¾bc),-7ehᦪO4hᦪ8“operator++

203஻ᑖ᪆hᦪ¿ᦪ᪷ÀÁbcᦪḄeᦪoperator++(Complex&cl)஻ᑖ᪆hᦪÂÃÄ9Complex&operator++(Complex&cl)ÂÃ1ÅK᝞4஻4.1µ¶7bc)ᡂᕒhᦪ§Complex&operator-()(this->a-;this->b-;return*this;}//4.2¤ᵨl-cljcl.printCom();//4.3µ¶7'(),-hᦪ8O4//cl.operator-()K᝞5஻5.1஻ƶ++bc)ᵨᐰhᦪ§Complexoperator++(Complex&cl,int)(Complextmp=cl;cl.a++;cl.b++j

204returntmp;)//5.2¤ᵨlcl++;஻ᐜ5ᵨÆ++//5.3ƶ++'(),-hᦪ8O4Complexoperator++(Complex&cl,int)஻hᦪᓰÈ¿ᦪɵ¶++oÊËK᝞6//6.1ƶ7bc)ᵨIᡂᕒhᦪ§Complexoperator--(int){Complextmp=*this;this->a-;this->b-;returntmp;}//6.2¤ᵨlcl++;஻ᐜ5ᵨÆ++//6.3ƶ-'(),-hᦪ8O4Complexoperator--(int)஻hᦪᓰÈ¿ᦪɵ¶--oÊ˵¶Éƶ'()ÌÍC++q¡7eᓰÈ¿ᦪᩭÊᑖµ¶'(Éƶ'(

205,-++Ï--ÐAAobjectj'()HÉ••ᨵ]Ò!"#$:-H-Aobject-Aobject4ᐗᡂᕒhᦪ,-A::Aoperator-H-();ÓÔAAobject.operator-H-();&ᕒ(ᦪ)friendAoperator++(A&);ÓÔAoperator++(Aobject);Õ¿ᦪ*"#$:Aobject-H-Aobject-§ᐗᡂᕒhᦪ,-A::Aoperatoi-H-(fun;ÓÔAAobject.operator;&ᕒ(ᦪ+:friendAoperator-H-(A&.int\;ÓÔAoperator-H-(AobjectO^O4'(),-hᦪ8ḄÖ×ᐰhᦪஹIᡂᕒhᦪl§'(),-Ö×1⌕½¾bc),-7ehᦪ.ᑏ¹hᦪ8roperator+2᪷bcᦪ.ᑏ¹hᦪ¿ᦪ3᪷ÙÚ.`ᗐhᦪÂÃÄÜhᦪÂÃÝᵨᢣ┐ᐗàá.â§hᦪÙÚᐗhᦪ§bc),-Ḅᵨ1ᐗhᦪÉᡂᕒhᦪ⌱äl>klæᦋÀbcᦪḄIè.5ᵨᐰhᦪ*+,->=,0,0É->bc)éq¡ᡂᕒhᦪ*+,-2ᵨᐗhᦪ,-<<>>bc)>istreamÉostreamC++Ḅ⚜O4ìI

206AcinistreamḄ#í.coutostreamḄ#íî'()«ᵫ஺stream,-Añᐭbc.ᵨòó¹{IPᦪî'()»ᵫistream,-A%õbc.ᵨòóᐭ{IPᦪîᵨᕒhᦪ,-«É»,ó¹ÉóᐭᵨᡝO4ḄᦪIPa)ᵨᐰhᦪl§«bc)ostream&operator«(ostream&out,Complex&cl)(//out«"12345,ö÷øù"endl;out«cl.a«"+"«cl.b«"i"«endl;returnout;)஻¤ᵨlcout«cl;஻úÒQwᢝcout«cl«"abcc";//cout.operator«(cl).operator«("abcd");஻hᦪÂÃÄᐙÀÄ◤⌕ÂÃ7eÝᵨb)Iᡂᕒhᦪlkl§«bc),-஻NüᑮcoutdeIḄþṹ//cout.operator«(cl);3)ᐗᦪᵨa)ᕒᦪᵨḄᦪḄ

207Qᕒ_ᦪ]^ᵨ;Ḅsaᦪ<¨Ḅ©ª᝞classComplex{intReal;intImag:public:Complex(inta){Real=a:Imas=0;}Complex(inta.intb){Real=a:Imag=b;}Complexoperator+(Complex);intf()/2”operator+(z){ComplexzL2.3)k(3,4);z=z+27/NOz27Complexஹ……«ᵨ_ᦪbᐸAᙠ#$%&ᦪ◤⌕◚*+ᣚḄ-./ᵨᕒᦪ012Ḅ⌱4>ᕒᦪ6ᨵthisᢣ┐/ᡠ◤ᦪ;<=ᙠ&ᦪ⊤?*@A/BC᧕EFḄ◚*+ᣚ>C++GHᵨᕒᦪḄᨵ=JKL—>4KᐗᦪᫀOvectorincludeusingnamespacestd;஻QvectorRSᐭUVWclassvector

208public:vector(intsize=1);Xvector஺;int&operator[](inti);friendostream&operator«(ostream&output,vector&);friendistream&operator»(istream&input,vector&);private:int*v;intlen;)Yvector::vector(intsize)(if(size<=0||size>100)(cout«"Thesizeof"«size«"isnull!

209";abort();)v=newint[size];len=size;)vector::Xvector஺{delete[]v;len=0;

210int&vector::operator[](inti)(if(i>=0&&i

211";abort();)ostream&operator«(ostream&output,vector&ary)(for(inti=0;i

212cout«"InputthelengthofvectorA:

213";cin»k;vectorA(k);cout«"InputtheelementsofvectorA:

214";cin»A;cout«"OutputtheelementsofvectorA:

215";cout«A;system("pauseH);)8.4VZ1[ᑴC++]^ᘤ0᝞abᢝ[ᑴḄd2ef=gefᵨhiᦪjḄkᑴoperator<=QᡂᕒᦪgᦪmQn&::operator=(const&);ᫀOnoᗐName/bᢝ=q஺

216#includeDName?ḄEFG)3ᦪ#includeclassName{public:Name(char*pN);Name(constName&);஻Hᑴ᪀⌼3ᦪName&operator=(constName&);஻EFG)K5LQName():protected:chai'*pName;size;)Ysᦋhiuvᵨefᦪvoidmain()/{NameObjl("ZhangS^n")NameObj2=Obj1/஻@ᵨHᑴ᪀⌼3ᦪNameObj30N஻@ᵨEFG)K5L3ᦪxy:1஻ᐜ}~Ḅᑁ2$%ᵨ3=ᔣ஻obj3=objl;஻C++]^ᘤVḄq//obj4=obj3=objl//obj3.operator12(objl)Name&operator=(Name&objl)(//Iᐜ}~obj3Ḅᑁif(this->m_p!=NULL)

217delete[]m_p;m_len=0;}//2᪷j஺bjlᑖµᑁᜧ·this->m_len=objl.m_len;this->m_p=newchar[m_len+l];஻3ºobjlef»obj3strcpy(m_p,objl.m_p);return*this;}3ᦪÀ.⊤LLUJK>[]UJK0Áᐗ>[]UJKÂHᵨᡂᕒᦪ/HᵨᐗᦪEFM᪗K5L[][]ᵨÃÄᦪjhiḄᐗÅÆ*?O?nnoperator[]?OYÇx0XḄ$%hi/ᑣ⊤É*x[y]ÊËÌ}Qx.operator[](y)

2181.EFM᪗K5LP஻-6.#includeclassvector{public:vector(intn){v=newint[n]:size=n;}-vector(){delete[]v;size=0;}v[i]cout«a[2]«endl;LEFM᪗K5LP஻-64#includeclassvector{public:vector(intn){v=newint[n]:size=n;}Xvector(){delete[]v;size=0;}

219Æ*?O?::operator()(⊤ST⊤)YUÇx0XḄ$%hi/ᑣ⊤É*x(argl,arg2,...)ÊËÌ}Qx,operator()(argl,arg2...)zᫀOn஻2ᵨEFK5LVᦪW3ᦪḄXY#includeclassF{public:doubleoperator()(doublex,doubley);}doubleF::operator()(doublexdoubley)z{returnx*x+y*y;}voidmain()f.getA();cout«f(5.2,2.5)«endl;//f.operatorf)(5.2,2.5)}ÏÐÑÒᡂᕒᦪ஻3ᵨEF()K5LVpkᡂᕒ3ᦪ#include

220classF{public:doublememFun(doublex,doubley);)YdoubleF::memFun(doublex,doubley){returnx*x+y*y;}voidmain()(FfYcout«f.memFun(5.2,2.5)«endl;)5QÓÔ⌕&&U||ᳮy×Øn1)&&U||0C++GÙᱯÛḄ2)&&U||ᑁÜEFÝÞßàᑣ3)0☠ᦪᩭoᡂḄ4)ᦪQᦪ&ᦪã⌴5)C++Ḅᦪ&ᦪ;åËæf/çèEFÞßàᑣ/include#includeusingnamespacestd;classTest

221inti;public:Test(inti)(this->i=i;)Testoperator+(constTest&obj)(Testret(O);cout

222//&&ᔣvoidmain()(intal=0;inta2=1;cout<<“n&&Ḅxᔠîï0ᔣ”<

223return;8.5ᙠ⚗÷øùGḄúᵨ1EF$%ᦪÀûüý»2EF$%ÿ᪀⌼ᦪ⌕MyStringa;MyStringa(஻dddd஻)MyStringb=a;ᵨḄ«»!===><=஻Cᨵ!"#$ᦪ%ᩭ'(஻C++ᡃ*ᩭ+,-./012ḄclassMyString(friendostream&operator«(ostream&out,constMyString&s);public:஻᪀⌼4᪆᪀

224MyString(intlen=0);MyString(constchar*p);MyString(constMyString&obj);~MyString();public:஻67MyString&operator=(constchar*p);MyString&operator=(constMyString&obj);char&operator[](intindex)const;public:booloperator==(constchar*p)const;booloperator!=(constchar*p)const;booloperator==(constMyString&s)const;booloperator!=(constMyString&s)const;public://stringtocchar*c_str();constchar*c_str()const;intlength()returnm_len;)

225public:intoperator<(constchar*p);intoperator>(constchar*p);intoperator<(constMyString&s);intoperator>(constMyString&s);private:intm_len;char*m_p;)3®ᢣ┐<¯ᑏi8⚪:;ᢣ┐>ᵨ$?!@A;BᑁDEF4ᑁDGHIJK2LMNᫀ:Q᝞SboostTḄUVᢣ┐⚗XYZ!⌕YZὅ>ᵨ⚜ᐜ^ᑏḄUVᢣ┐`abcCḄdeᢣ┐3UVᢣ┐fgh?ḄUVᢣ┐"-.'i#$᪀⌼ᦪjkᵭmḄᑁD#$᪆᪀ᦪnoᚮᑁDIqrJK#$67ᢣ┐st*4->ᩭ'(ᢣ┐Ḅwx#$67yzst==4!=ᩭ'(ᢣ┐Ḅyz

226classTest(public:Test()(this->a=10;)voidprintT()(cout«a«endl;)private:inta;)classMyTestPointer(public:public:MyTestPointer()p=NULL;

227)MyTestPointer(Test*p)(this->p=p;)~MyTestPointer()(deletep;)Test*operator->()(returnp;)Test&operator*()(return*p;)protected:Test*p;)voidmain01_classp()

228Test*p=newTest;p->printT();deletep;MyTestPointermyp=newTest;஻᪀⌼ᦪmyp->printT();஻67->)classMylntPointer(public:public:MylntPointer()(p=NULL;)MylntPointer(int*p)(this->p=p;)~MylntPointer()

229deletep;)int*operator->()(returnp;}int&operator*()(return*p;)protected:int*p;}voidmain02_intp()(int*p=newint(lOO);cout«*p«endl;deletep;MylntPointermyp=newint(200);coutcv31cmyp<

2308.7▬|Sst41᪶ឋ▬²C³oᔠឋ⌕´lᐜn¢ioᔠᔣḄ5ᦪ()ᙊ¹º[]¿᪗1ᢣᔣo᪀Äᡂᕒ»¼—>•o᪀ÄᡂᕒÅÆÇ=ᢥGÍÎ++»Ð——»Ñ12—Òº»¼ÈᓫÊËÓ<¨Ë<¨Ôᣚᢣ┐&ÍᙢᙬsizeofÙÚ*Ûy23/◀y»¼ÈÜÊË%´Þ+ßy24»¼—àyÈÜÊË«á25»¼»áÈÜÊâ26<<=>>=ᐵ廼ÈÜÊË

231æ⊤⌕´lᐜn.¢ioᔠᔣḄ5ᦪ==ç;27!=»¼ç;ÈÜÊË28&ᢥGI»¼ÈÜÊË29AᢥGèᡈ»¼ÈÜÊË2101ᢥGᡈ»¼ÈÜÊË211&&ÅÆI»¼ÈÜÊË212IIÅÆᡈ»¼ÈÜÊË313?tᩩ껼ÈëÊË=+=—=*=214/=%=»=«=컼ÈÜÊË&=A=S=⌹º15»¼Èîï´Ë167"C++Ḅᜧᱯឋ-67Ḅ"#$ᦪ᡽Ḅoperatorᐵ"67Ḅᐵfriendᐵ/`ᦪᡈYZ8ᩗ▲67⍳ᦪ67Ḅᑣ67/¢j>ᵨḄᡂᕒᦪ¥B=,§,¨©4-ª«V#$ᡂᕒᦪ¬w67++#$-.intᦪ¬w®¯°±¯Ḅ67C++²⌕67&&411

232

2333ஹ´µ4¶e3.1´µᭆ¸☢ᔣ`a?»+,ᨵ4.¼⌕ᱯ½S¾aஹ¿Àஹ´µ4G᝱ឋ஺ᡃ*Ã@ÄLÅ4`a!ÅLÅ☢ᔣ`a?»+,ḄÆ.6⌕ᱯÇ-ᦪȾa°¿À!É@VÊ+,;ËÌ`aḄ?»!"☢ᔣ`a?»+,ḄËẠ஺⌕zÎᙢ¬w☢ᔣ`a?»+,!ÐÑÒÅL☢ᔣ`a?»+,Ó᜜Æ.6⌕ᱯÇ--´µឋ4G᝱ឋ஺Õ¼⌕Ö×ᨵᐵ´µḄØÙ!G᝱ឋÚᙠ±ÜÕ⁚ÄL஺´µឋ"☢ᔣ`a?»+,ᨬ6⌕ḄᱯÇ!/ß!᝞àᨵáâ´µឋ!ãäÌᨵáâ4`aḄåæ!ã"ᨵáâ☢ᔣ`a?»+,Ḅçè஺3.1.1éḄᐵêhas-A,uses-A4is-Ahas-Aᒹìᐵê!ᵨ/íî-.ᵫG."ñò"᪀ᡂ஺¥Bhas-Aᐵêᵨᡂᕒ⊤ô!ᓽ-.ḄᦪÈᡂᕒ"Ó-Ã@öḄ஺uses-A-.ñᑖᙢ>ᵨÓ-.஺#$éᡂᕒᦪḄøùὶê!öûᕒᡈ`aᦪü⌴¥B஺is-Aþᑴ""஺ᐵᐹᨵ⌴ឋᐹᨵឋ஺3.1.2ᐵᱥḆᨵ⌕Ḅᫀ!1"ᱥ#$2%&ᕒ#

234Hçðᱥõçðᱥòóᙢ⊟

2353.1.4+,-Ḅ./56ᐵ8Ḅ9:;$class<=:>⊤{ᦪ@ᡂᕒBᡂᕒ(ᦪCD};>⊤᪀ᡂEFGᑴ>௃JEFGᑴ>2,EFGᑴ>"⊤Ḅᵨᐵpublicᨵprivate"ᨵprotected#$23:C++Ḅ56(publicஹprivate>protected)89:;-Ḅ᜜=>?ឋ஺3.1.5⌕@A1ஹ;-Bᨵ᱄-ḄᡠᨵᡂᕒFGHᡂᕒIᦪ4ஹ;-KLBᨵ᱄-MᨵḄ5NH?ឋ2ஹ;-OPQᱯSḄ᱄-3ஹ;-KLTU᱄-Vᵨ3.2+,-Ḅ=>Xᑴ+,-Z[-Ḅᐰ]ᡂᕒFGHᡂᕒ5N(◀Z᪀⌼H᪆᪀c᜜Ḅᡂᕒ5N)efgᡂᕒḄ=>?ឋᙠ+,i%KLj᦮Ḅ஺

2363.2.1ᓫ-Ḅ=>Xᑴ1ஹ-ᡂᕒ=>mn(publicஹprivate>protected)2ஹoὃ!-ᡂᕒḄ=>mnqᨵpublicHprivateᔲstu3.2.2vḄ568ᦋFᡂᕒḄ=>?ឋ1)C++Ḅ5689:;-Ḅ᜜=>?ឋpublic!᱄-ᡂᕒᙠ;-xᢝzᨵ=>mnprivate!᱄-ᡂᕒᙠ;-Fprivateᡂᕒprotected!᱄-publicᡂᕒ8Fᡂprotected᱄-protectedᡂᕒ{ᯠprotected᱄-privateᡂᕒ{ᯠprivate2)privateᡂᕒᙠ;-}ᯠ~ᙠeᓾN=>ᑮ஺Q56[-+,-Vᵨ[-Ḅᨵᡂᕒ஺3)C++;-᜜=>?ឋ⊤᱄-ᡂᕒ=>mnpublicprotecedprivatepublicpublicprotecedprivate5protecedprotecedprotecedprivate6privateprivateprivatePrivate4)Ḅ=>Xᑴ

237classA(public!inta;protected:intb;private![intc;$classB:publicApublic!inta;protecteded:c-private!intb;$:intc;mainOmam(a;//errb;;//errc;//err3.2.3“”zᑣC++Ḅ56£publicஹprivatexprotected89:;-Ḅ᜜=>?ឋᑨ¥¦P§¨ᔲ©=>1jᵨª§f§¨ᑏᙠ;-Ḅᑁ]ஹ᜜]2;-᝞®¯᱄-£public>private>protected3᱄-Ḅ=>mn£publicஹprivateஹprotected3.2.3+,--ᡂᕒ=>mn°±Ḅzᑣoὃ!᝞®ាTḄVᵨpublic,protectedHprivateᡂᕒ³A=>mnu1ஹ◤⌕©᜜µ=>Ḅᡂᕒ°±public2ஹqᙠT¶-=>Ḅᡂᕒ°±private3ஹqᙠT¶-H;-=>Ḅᡂᕒ°±protected,protectedᡂᕒḄ=>ᩗ▲¹T'publicHprivatecº஺

2383.2.4»ᔠ½¾¾¿!public8ᦋF᱄-᜜=>?ឋ$private8ᦋF᱄-᜜=>?ឋprivate$protected8]ᑖᦋF᱄-᜜=>?ឋ஺Á!PÂÃÄÅclassB:publicA஻-Ḅ56;-᜜=>?ឋ9:#includeincludeusingnamespacestd;classA(private:inta;protected:intb;public:intc;A()

239a=0;b=0;c=0;)voidset(inta,intb,intc)(this->a=a;this->b=b;this->c=c;))$classB:publicA(public:voidprint()(//cout«"a="«a;//errcout«"b="«b;cout«"c="«endl;))$

240classC:protectedA(public:voidprint()(//cout«"a="«a;//errcout«"b="«b;cout«Hc="«endl;)$classD:privateA(public:voidprint()(//cout«"a="«a;//errcout«"b="«b«endl;cout«"c="«c«endl;))$intmain_01(intargc,char*argv[])

241Aaa;Bbb;Ccc;Ddd;aa.c=100;//okbb.c=100;//ok//cc.c=100;//err-Ḅ᜜]ÇÈÉ///dd,c=100;//erraa.set(l,2,3);bb.set(10,20,30);//cc.set(40,50,60);//ee஻dd.set(70,80,90);//eebb.print();cc.print();dd.print();system("pause");return0;

2423.3Ḅ᪀⌼H᪆᪀3.3.1-ÊËÌឋzᑣ-ÊËÌÍᑣᢣᙠ◤⌕[-ḄÏ®ᙢ5KLVᵨÑᨵ+,-ḄᩭÓÔ஺ÕiÑᨵ+,-ÖᑮZ[-◀᪀⌼Iᦪஹ᪆᪀Iᦪc᜜Ḅᡠᨵᡂᕒ஺f᪵Ñᨵ+,-Ø▭OᐹᜓZ[-ḄᡠᨵÛÜ[-ÝÞḄ>⚪Ñᨵ+,-KLÝÞ஺-ÊËÌÍᑣᡠᢣḄÓÔᒹáLÅÃÄ!;-KLTU᱄-Vᵨ;-KLâãä᱄-;-KLåæᓄ᱄-᱄-ᢣ┐KLᢣᔣ;-᱄-êᵨKLêᵨ;-ᙠÓÔcë+,-OKLU[-ḄVᵨeqVᵨ¯[-Ḅᡂᕒ஺-ÊËÌÍᑣì᝱ឋḄ⌕[ẠcP஺ïÁ!;-OᱯSḄ᱄-(base*p=&child;)/♦include#includeusingnamespacestd;/*;-KLTU᱄-Vᵨ;-KLâãä᱄-;-KLåæᓄ᱄-

243᱄-ᢣ┐KLᢣᔣ;-᱄-êᵨKLêᵨ;-*/஻;-OᱯSḄ᱄-classParentO3(protected:constchar*name;public:Parent03()(name="Parent03";)voidprint()(cout«"Name:"«name«endl;))$classChild03:publicParent03{protected:inti;

244public:ChildO3(inti)(this->name="Child2”$this->i=i;));intmain()(ChildO3child03(1000);஻ᑖn./᱄-᱄-ᢣ┐᱄-êᵨchildParent03parent=childO3;Parent03*pp=&childO3;Parent03&rp=childO3;parent.print();pp->print();rp.print();system("pause");return0;

2453.3.2ḄñÊ-ᙠC++òóᘤḄᑁ]KLᳮÝÁ᪀ö;-ᵫ᱄-ᡂᕒøù;-úᡂᕒÖᑮḄᨵ\]Ḅ^_i?includeclassA{public:voidget^XYQ{cQut«"Entertwonumbersofx.y!H$cin»x»y$}voidputXYQ{cout«Mx=',«x«n.y="«y«':}Cjrotected:hclassB:publicA{public:intget^S(){returns;voidmake_S(){s=x*v!}!(^protected:}?classC:publicB{public:voidget_H(){cout«MEnteranumberofh:";cin»h;}intget_V(){returnv:}^oidmakeS():v=get_S()*h;)ᵨ`?ᡂᕒ3ᦪprotected:tatKvi^)(

246voidmain()ᨵ\]Ḅ^_{AobjA;xyBobjB;objAobjA.xobjA.yCobjC:Scout«wItisobject_A:

247H;objBobjB.xobjB.yobjB.shvobjA.get_XYO$objCobjC.xobjC.yobjC.sobjC.hobjC.vobjA.putXY():cout«MItisobject_B:nu;objB.get_XY();)ᵨAᡂᕒ+ᦪobjB.make_S();cout«MS=M«objB.getxf^<^ndl;஺bjCḄᦪ.ᡂᕒ/0cout«MItisobject_Czn;objC.get_XY();/objC.get_H():objC.make_V();cout«nV="«objC.get_V()«endl;}᪀⌼H᪆᪀>⚪!᝞®åæᓄ᱄-ᡂᕒu᱄-û;-Ḅ᪀⌼IᦪᨵÇÈᐵᙠ;-᪀⌼ü◤⌕jᵨ᱄-᪀⌼IᦪᐸÖᩭḄᡂᕒþÿᓄᙠ᪆᪀◤⌕ᵨ᱄᪆᪀ᦪᐸᩭḄᡂᕒᳮ#include#includeusingnamespacestd;classParent04(public:Parent04(constchar*s)

248cout«"Parent04()"«""«s«endl;)~ParentO4()(cout«"~Parent04()"«endl;)classChild04:publicParent04(public:Child04():ParentO4("ParameterfromChild!")(cout«"Child04()"«endl;)-ChildO4()(cout«"-Child04()"«endl;)

249voidrun04()(Child04child;)intmain_04(intargc,char*argv[])(run04();system("pause");return0;3.3.3Ḅ᪀⌼᪆᪀ᵨ"ᑣ1ஹᙠ%&'✌ᐜᵨ᱄Ḅ᪀⌼ᦪ2ஹ᱄᪀⌼ᦪ᡻+,-᡻Ḅ᪀⌼ᦪ3ஹ.᱄Ḅ᪀⌼ᦪᨵ0ᦪ◤⌕ᙠḄᓄᑡ⊤34ᵨ4ஹ᪆᪀ᦪᵨḄᐜ-567᪀⌼ᦪ893347:ᔠ<=>?@᪀⌼A᪆᪀ᵨ"ᑣ"ᑣBᐜ᪀⌼᱄C᪀⌼ᡂᕒDEஹᨬ-᪀⌼GHᐜ᪆᪀GHᙠ᪆᪀ᡂᕒDEஹᨬ-᪆᪀᱄஻ᐜ᪀⌼Ḅ-JKLMBdemo05_extend_construct_destory.cpp

250஻᝞Pᓄ᱄ᡂᕒ஻Ḅ᪀⌼A᪆᪀஻A:ᔠ<=>?@᪀⌼ᦪஹ᪆᪀ᦪᵨ56ẆR#includeusingnamespacestd;classObject{public:Objectfconstchar*s)(cout«"Object()"«""«s«endl;)SObject஺(cout«"~Object()"«endl;)}classParent:publicObject

251public:Parent(constchar*s):Object(s)(cout«"Parent()"«""«s«endl;)SParent஺(cout«"~Parent()"«endl;))classChild:publicParent(protected:Objectol;Objecto2;public:Child():o2(”o2"),olC'ol"),Parent("ParameterfromChild!")(cout«"Child()"«endl;)SChild஺cout«"rwChild()"«endl;

252));voidrun05()(Childchild;)intmain05(intargc,char*argv[])(cout«"demo05_extend_construct_destory.cppH«endl;run05();system("pause");return0;3.3.5ḄUVᡂᕒDEᜐᳮXY1ஹ.ᡂᕒDE7᱄ᡂᕒDEUV2ஹZᯠ\᱄UVᡂᕒ3ஹᙠ]^_ᵨ`ᑖbc::UVᡂᕒeᑖfᙠghiᵨjḄUVᡂᕒ3kᙢiᵨV▲nco4ஹUVᡂᕒpqᙠᑁpḄsUtu

2531.Eaᦪ#ᡂᕒBbaseab:classbase;derivedabb{public:inta,b:derivedd1234};classderived:publicbase{public:intb.c:};voidf()ᡂᕒḄ0ᵨ123ᑮᡠᨵ{derivedd;d.a=1;AḄ78ᡂᕒ9:Ḅ;8ᡂᕒd.base::b=2:d.b=3:d.c=4:);2.Eaᡂᕒ3ᦪ^includeclassA{public:intal.a2;A(intil=Ointi2=0){al=il;a2=i2:}rvoidprintO{cout«"al="«al«,Xt*«"a2="«a2«endl;}classB:publicAghvwjUVᡂᕒᦪ{public:ᵨGxḄᡂᕒᦪintbl.b2;B(intjl=lintj2=l{bl=jl;b2=j2:}?voidprint()//M(ᦪ{cout«Hb”

2543.3.6ghḄstaticᐵ{|Astaticᐵ{|ᙠ}~'hᳮjnḄ☟᝱ᡂᕒᡠᨵghᐳ᪷☟᝱ᡂᕒGxḄᱯឋAghḄXkᙠᐹᨵsUḄឋf⍳ghḄᑴogh☟᝱ᡂᕒᵨ¡@¢k3k£¤B?a::ᡂᕒᡈ]^Ya.ᡂᕒᙠcd?l☟᝱ᡂᕒ==includeclassB☟᝱ᦪᡂᕒ{public:ain()staticvoidAdd(){i-}{BXDystaticinti;x.Add();voidoutQ{co}(x.out();intB::i=0;y.f();classD:privateB{public:cout«Mstatici=M«B::i«endl;voidf():cout«Mstatici=M«x.i«endl:{i=5cout«nstatici=',«y.i«endl;Add():B::if}B::Add():

255஻J5ᙠcd?l☟᝱ᡂᕒ#includeclassB{public:voidmain()staticvoidAdd஺{i-H-}{Bx;Dystaticinti;x.Add();voidout(){cout«Mstatici=,,«i«endl;}};x.outQ};0஻7-5ᙠcd?l☟᝱ᡂᕒ^includeclassB{public:voidmain()staticvoidAdd஺{i++}{Bx:DvBstaticinti;BḄ☟᝱ᦪᡂᕒx.Ad^tkvoidout(){coutv"oiailL1ஹjx.out();JiintB::i=0;y-fOBclassD:privateB{public:cout«"statici="v«^B::i4?:

2561>staticᦪ®⍳3°"ᑣ2>static᧕³┯µfs¶⌕ᓄ·¸⌕Ḅ34Ḅ¹º»¼ᘤᑖ¾ᑁpo3>᪀⌼ᦪ¿ÀÁprivate3.4Æ3.4.1ÆḄÇᵨÆᭆÉ>}°ᨵÆ°ÊËjḄᐵÌÁÆ>ÆͤÎYclasscd?amᑴ`?a1,ᑴ`?a2,....ᑴ`?an{ᦪ#ᡂᕒᡂᕒ3ᦪnoo>CÑ¡᪷ᑴUAABḄᡂᕒÔÕÖGHḄᡂᕒÆḄgh᪀⌼A>Æ°jḄgh᪀⌼ᦪÑ¡ᵨkᵨj᪀⌼ᦪᓄᦪᡂᕒ>᡻567ᓫ᪀⌼ᦪ>?Ø஺Æ°ÊËj᪀⌼ᦪ᡻56ÙÚÛnghᢣnḄᔜ°jḄ56஺>}°ghÞᨵÆ°ÊËᡈßËjḄᡂᕒ஺sUVᡂᕒs'àáឋ஺᝞âsUḄjᨵUVᡂᕒghÇãÖ¡ä஺

257ÆåᓫÇᵨp\]Ḅqᓫsᵨvoidmain(){Baselbl(10);classBaselBase2b2(*k');{public:Basel(intx){value=x;}Derivedd(52.5);intaetDataOconst{returnvalue:}protected:intvalue;return;};.classBasel{public:Base2(charc){letter=c;}chargetDataOconst{returnletter:)protected:charletter;);classDerived:publicBasel,publicBasel{friendostream&operator«(ostreamconstpublic:Derived(mt.charBdouble);double^etResdQconst;private:doublereal;)(3.4.2æ᝞â}°gh\Æ°jghçèéjêᨵ}°ᐳUḄjᑣᙠãjÍ

258CḄ8DEFGHIJKឋ᝞:classB{public:intb:}:classBl:publicB{private:int^bl;};classB2:publicB{private:intb2:};classC:publicB1.publicB2{public:int^f():private:intd:}:classC(f().d)ᨵ:Cc;c.B;//errorc,B::b;//error,tuv\]Ḅ?c.Bl::b://ok,tBl\]Ḅc.B2::b;//ok,tB2\]Ḅᑖ᪆:᝞:classB{public:intb;};classB1:publicB{private:intbl;}:classB2:publicB{private:intb2:};classC:publicB1.publicB2{public:intf();private:intd;}:pEcd?CḄYḄxyz᪀>{CḄBḄ᪀⌼ᦪᵨᵫB1ᵨᵫB2ᵨᓄCḄᡠᒹḄBḄ>?:

259>᝞â}°gh\Æ°jghçèéjêᨵ}°ᐳUḄjᑣᙠãjͤḄV|Ñëháឋ>᝞âᙠÆᩩíîïᨵ}°ðᐳḄjñᙠíîḄòᜐóᔠôè°ðᐳjõ'ᙠghḄhÆ°j>⌕iè°ðᐳjᙠghöh}°÷øè°jͤÁæiè°jᡂÁæj஺>æͤiᵨᐵ{|virtual᝞:classB{public:iiHb:};classBl:virtualpublicB{private:intbl;}classB2:virtualpublicB{private:iiHb2;}classC:publicBl.publicB2{private:floatd;};ᨵ|Ccc:cc.b//ok/QᵫCḄᨵBbᑮ"#ᡠ%&%'()*+ᵨb-.BḄ/ᡠ-.Ḅ0123Ḅ4஺ᓽcc.B1::b7cc.B2::b8ᵨ1(4BḄ

260-᝞:classB{public:intb;};classBl:virtualpublicB{private:intbl;};classBclassB2:virtualpublicB{private:intb2;}:—MclassC:publicB1.publicB2classBl{bl)|{private:floatd:};OᨵP>Ḅ<=cḄQḄRST᪀VWclassC{d}ùúBûüýÖvirtualᐵ{|-᪀⌼ᦪᵨḄᦪ஺3.5y+>þ☢ᔣᵨḄ⌕஺ᕒᙠᨵḄẠḄ஺>ᓫ$%Ḅ&ᨵ'(஺)$%Ḅᨵ)(஺>ᡂᕒḄ+,ᵫ$%./ᡂᕒឋ12஺>3456ᐜ8ᵨ᪀⌼;ᦪ=>ᓄ@Ḅᡂᕒ஺8ᵨ᪆᪀;ᦪḄB/8ᵨ᪀⌼;ᦪḄBCD஺>C++EFG$%Hᑴ6■K$%ᐵM@ᡂᕒ+,ḄNឋ஺)$%EFOᵨḄPᜧRS6TUVOḄWᩖឋ஺

2614ஹ)᝱,⚪\](_`abឋcᑣ⍗;ᦪᑏ)☢ᔣ◤jC++EFḄ)᝱k2ᫀ)᝱ᫀm)᝱no☢ᔣpᜧᭆrஹps᛻u(vwஹ$%ஹ)᝱))᝱ᡂxᩩz{ᩩஹ|}ṹḄ5᎛⌕|])᝱4.1)᝱4.1.1,⚪\]᝞O᱄@cCḄ;ᦪ;ᦪᑏᙠ@᱄@cCḄ;ᦪ;ᦪᑏ&ᙠ᱄classParent(public:voidprint(){cout«"Parent:print()do..."«endl;)

262);classChild:publicParent(public:voidprint()(cout«"Child:print()do..."«endl;))intmainOl()(runOO();/*Childchild;Parent*pJNULL;p=fechild;child,print();child.Parent::print();*/system("pause");return0;

263)᱄@ᑏḄ;ᦪ®ᯠ$%°±²³´µ@ᑏḄ;ᦪ¶◚¸᱄@Ḅ;ᦪ¹º»ᵨ¼ᑖ¾¿::+,ᑮ᱄@◚¸Ḅ;ᦪC/C++Á☟᝱ÃÄÅÆᙠÃÄ56ÃÄᘤÈÉ᪷Ëᢣ┐ḄᑨÏᢣᔣḄÁ'(᪵Ḅ*//*1ஹᙠÃÄÒ;ᦪḄ56ÃÄᘤÓSÔ⍝ᢣ┐PÖ×ᢣᔣO஺2ஹÃÄᘤØᨵᳮᵫÚ┯஺3ஹÜÁ6ÃÄᘤ²ÝᨬßᐰḄáÁÃÄᑮ᱄Ḅprint;ᦪ6âÝ᱄/ãäᨵCḄprint;ᦪ஺*/஻☢ᔣ◤j஻᝞ᡃç'(᱄6᡻é᱄Ḅprint;ᦪ஻᝞ᡃç'(6᡻éḄprintf;ᦪ஻êḄcâ஻_`abឋcᑣ⍗;ᦪᑏ]Ḅ'(

264//IØᨵᳮᵫÚ┯஻28ᵨ;ᦪᩭì6ᙠÃÄᘤÃÄí6ᡃîïO6ð(;ᦪḄñᦪÁp,ÁParentḄ஺஺஺஻3☟᝱òÃ஻nó@᝞ôᑨÏÁÓÁ)᝱õᙠ/*ᙠ'(ö☢S;ᦪ÷$%Ḅ³´µ6ᑏ÷Ó'ᑏḄ☟᝱ὶÃ÷ÁÉ᝱ὶÃ*/#includeusingnamespacestd;classParent(public:voidprint()cout«"Parent:print()do..."«endl;

265));classChild:publicParent(public:voidprint()(cout«"Child:print()do..."«endl;)/*1ஹᙠÃÄÒ;ᦪḄ56ÃÄᘤÓSÔ⍝ᢣ┐pÖ×ᢣᔣO஺2ஹÃÄᘤØᨵᳮᵫÚ┯஺3ஹÜÁ6ÃÄᘤ²ÝᨬßᐰḄáÁÃÄᑮ᱄Ḅprint;ᦪ6âÝ᱄/ãäᨵCḄprint;ᦪ஺*/voidhowToPrint(Parent*p)(p->print();)voidrun00()

266Childchild;Parent*pp=&child;Parent&rp=child;//child.print();஻¹ºᢣ┐//pp->print();஻¹º\ᵨ//rp.print();howToPrint(&child);)intmain01()(runOO();/*Childchild;Parent*p=NULL;p=&child;child.print();child.Parent::print();

267*/system("pause");return0;}4.1.2☢ᔣ◤jÃÄᘤḄáÓÁᡃùíúḄ᪷Ë▭ḄᩭᑨÏᑏ;ᦪḄ8ᵨ᝞᱄ᢣ┐ᢣᔣḄÁ᱄ᑣ8ᵨ᱄@Ḅ;ᦪ᝞᱄ᢣ┐ᢣᔣḄÁᑣ8ᵨ@Ḅᑏ;ᦪ☢ᔣ@Ḅ)᝱᪷Ë▭Ḅ2;ᦪ8ᵨÅüḄᐹþ8ᵨÿ᪗uoidprint()-ᔣ᱄'cout«,,I,nParent...,,<p->print();-uoidprint()ᔣ᝱᪵ḄᵨᨵḄ⊤᝱4.1.3ᫀ>C++!"virtualᐵ$%᝱&'(ᢝ>+ᵨvirtual,-Ḅ.ᦪ01ᑏ3ᓽ56᝱ᱯឋ

2684.1.4᝱9:#include"iostream"usingnamespacestd;classHeroFighter(public:public:virtualintackPower()(return10;)};classAdvHeroFighter:publicHeroFighter(public:virtualintackPower()(returnHeroFighter::ackPower()*2;)};

269classenemyFighterpublic:intdestoryPower(){return15;));஻᝞>?@AB᪀DᙠF᝱GH☢஻ᑏJKA᪾MN5Oᵨ஻ᡃḄQ3RᡊTRṹVḄWXYZ᪾MVḄWX஺஺஺஺஻᪾Mᨵ+ᵨ3ᩭ]ᑏḄRṹḄ^_஺஺஺஻☢ᔣ3ᜧᭆb/*efgẚJCi.ᦪḄᭆb஺஺jkRṹlᵨ஺஺஺஺ᡃlᵨmᩭᑏnḄRṹ஺஺஺᝱᝱5O+ᵨoᩭ஺஺஺஺஺80pRᑏJKA᪾M஺஺஺஺஺஺90]ᑏḄRṹ

270᝱qᡃrst'uvwḄKAx᪗஺஺஺////*///voidobjPK(HeroFighter*hf,enemyFighter*enemyF)(if(hf->ackPower()>enemyF->destoryPower())(printf("{|ᡭ~]…ᑭ

271");)else(printf("{|஺஺஺ᱨ

272“);}}voidmain()(HeroFighterhf;enemyFighteref;objPK(&hf,&ef);AdvHeroFighteradvhf;

273objPK(&advhf,&ef);systemCpause*');4.1.5᝱஻☢ᔣ3ᜧᭆb/*efgẚJCi.ᦪḄᭆb஺஺jkRṹlᵨ…஺ᡃlᵨmᩭᑏnḄRṹ஺஺஺᝱᝱5O+ᵨoᩭ஺஺஺஺஺80pRᑏJKA᪾M஺஺஺஺஺஺90]ᑏḄRṹ᝱qᡃrst'uvwḄKAx᪗஺஺஺஻ᑏJKA᪾MN5Oᵨ3ᩭ]NᑏḄRṹḄ^_////*/4.1.6᝱ᡂḄᩩt஻XᡂḄ3Aᩩt//IA஺஺஺

274//2ᐵὶ஺஺஺஺஻3*p஻᝱ᡂḄAᩩt//I⌕ᨵjk஻2⌕ᨵ.ᦪ1ᑏ஺஺஺C.ᦪ஻3⌕ᨵ᱄ᢣ┐᱄¡ᵨ¢ᢣᔣ஻᝱q£¤¥¦Ḅ§ẠN᝱q᪾MḄ§Ạ4.1.7᝱Ḅᳮª§Ạ01☟᝱ὶ¬F᝱ὶ¬1ஹὶ¬qᢣKA¯¥ᙽஹRṹ±X²³ᐵὶḄ"஺2ஹ☟᝱ὶ¬staticbinding,q¯Ḅᓛµஹ¶ᙠ¬·▤¹9Nº»¼½¾ᓛµ஺1¿.ᦪ+ᵨ☟᝱ὶ¬஺3ஹF᝱ὶ¬qᢣ¯ὶ¬ÀÁᑮÃ'W&'NᡠOÅ»¼Y¾ὶ¬ÁÆ¢஺switchifqF᝱ὶ¬Ḅ:஺4ஹᳮªὶÇ9▭1ஹC++ÉC³Nq☟᝱¬·Êi2ஹᙠ¬·WN¬·ᘤÌF᪷Îᢣ┐ḄÊᑨÐᢣᔣḄqKAÑÒ᪵Ḅ;ᡠO¬·ᘤÓ¼᱄ᢣ┐ᢣᔣḄq᱄஺3ஹᵫZ¯ÕᨵÃ'NᡠO5^Ö⍝᱄ᢣ┐ᢣᔣḄᐹÙq᱄ÚqÛ¯ÜᐰḄÞßN¬·ᘤᎷ£᱄ᢣ┐áᢣᔣ᱄Nâ㬷ḄB>¼ᵨ᱄Ḅᡂᕒ.ᦪ஺@ᱯឋåq☟᝱ὶ¬஺

2754.2᝱³ᐵ☢æ⚪☢æ⚪1:èééê᝱Ḅᳮ᝱Ḅ9ᦔ>᝱᪵ḄᵨᨵḄ⊤᝱;᝱9ḄAᩩtᨵjkஹᨵvirtual1ᑏஹᨵ᱄ᢣ┐¡ᵨ¢ᢣᔣ஺᝱ḄC++9virtualᐵ$%Nìí¬·ᘤ@A.ᦪ⌕(ᢝ᝱;q᪷Îᢣ┐ÊᑨÐ᝞îᵨ;ïq⌕᪷Îᢣ┐ᡠᢣᔣḄ9▭ÊᩭᑨÐ᝞îᵨ᝱Ḅᳮª§ẠF᝱ὶ¬PK☟᝱ὶ¬஺᪷Î9▭ḄÊᩭᑨÐ1ᑏ.ᦪḄᵨ஺᝱Ḅ1⌕£¤¥¦Ḅ§Ạq᪾MḄ§ð஺9᝱Ḅᳮª§Ạ.ᦪᢣ┐ñ.ᦪòᦪC.ᦪᢣ┐qC++óôõöḄ₫ὀ஺C.ᦪᢣ┐Kùᨵᵨúûஹü¢஺᝱mᳮýþÉ☢æÿ☢⚪2C++ᘤ᝞᝱C++ᘤ᝱ᳮ☢⚪3ᑏᳮᦪ

276ᙠ!"#$%&'($)*᱄$Ḅᦪ᱄$!-ᦪ./-0⌚2ᙠ34᪷67ᦪ$89#ᦪ:;ᦪ<ᵨᦪᑏ>?@᱄$A($B4CD᱄$A($%ḄᦪᨵFᐰH!Ḅ8IᵨvirtualJKBLMNO?᝱P᝞QRIᵨvirtual,ST;UV᝱ᙠW'34᪷6ᐹYZḄ$8:;ᦪ<ᵨ#includeincludeusingnamespacestd;classParentOl(public:ParentOl()(cout«"Parent01:printf()..do"«endl;)public:virtualvoidfunc()

277cout«"Parent01:voidfunc()"«endl;)virtualvoidfunc(inti)(cout«"Parent:voidfunc(inti)"«endl;)virtualvoidfunc(inti,intj)(cout«"Parent:voidfunc(inti,intj)"«endl;))[classChildOl:publicParentOl(public:஻]ᜐ2#7ᦪ9($funcᦪ_`ᐵbvoidfunc(inti,intj)cout«"Child:voidfunc(intiintj)"«""«i+j«endl;z)

278஻]ᜐ3#7ᦪḄ9($funcᦪ_`ᐵbvoidfunc(inti,intj,intk)(cout«HChild:voidfunc(intiintj,intk)"«""«i+j+k«endl;z})[voidrun01(Parent01*p)(p->func(l,2);)intmain()(ParentOlp;p.func();p.func(l);p.func(l2);zChildOlc;஻c.func();஻c⚪1c.ParentOl::func();

279c.func(l,2);run01(&p);run01(&c);system("pause");return0;}஻c⚪1dchildZef᱄$ZḄfunc,gchijMW'ᔩlwhy஻c.func();஻mn-0⌚2C++ᘤRop᱄$%qr0#7ᦪḄfuncᦪsoᙠ($%rfuncᦪ஺//I($u☢Ḅfunc)*᱄$u☢Ḅfunc஻2v᱄$9($ᨵH!Ḅᦪ-ஹxy-z>?-0⌚2(($Ḅᦪ-⌚2|᱄$Ḅᦪ-஺)//3//c.Parent::func();஻c⚪2($Ḅ~#func9᱄$uḄ#funcᦪ_`ᐵbl

280☢⚪4ᔲ$Ḅ#ᡂᕒᦪJKnᦪn_`oC++ᘤ᝱ᳮ☢⚪5᪀⌼ᦪ%<ᵨᦪM᝱ᔩln_`lC++ᘤ᝱ᳮ☢⚪6ᦪ⊤ᢣ┐(VPTR)/ᘤᓄḄ᝞ᳮḄlC++ᘤ᝱ᳮ☢⚪7᱄$Ḅ᪀⌼ᦪ%<ᵨᦪM>?᝱ᔩlC++ᘤ᝱ᳮ☢⚪8n_`⌕;U᪆᪀ᦪlᙠ_`vJKᦪ>᪀⌼ᦪRMᦪ஺"#?$Z$Ḅ᪷Ḽef¡¢⌲#<ᵨ¤$Ḅ᪀⌼ᦪ>᪆᪀ᦪ¥Ḅ஺᪆᪀ᦪᵨ@ᢣ¦deleteW§¨©ª᪆᪀«᝱Z

2818-4᪆᪀3ᦪᙠᑤ◀᝱cd?YḄ@ᵨ#includeclassA{public:QA(){cout«"A::QA()iscalled.

282";}᪆᪀ᵫ¤$ᢣ┐Ḅ?$ZclassB:publicA{public:°ᨵ<ᵨ?$᪆᪀ᦪQB(){cout«"B::¬iscalled.

283"voidmain(){A*Ap=newB;B*Bp2=new/;cout«”delᰄfirstobject:

284";deleteAp;cout«"deletesecondobjecr:

285":deleteBp2:}8-4᪆᪀3ᦪᙠᑤ◀᝱cd?YḄ@ᵨ#inchideclassA{public:QA஺{cout«"A::-AQiscalled.

286";})(classB:publicA᪆᪀ᵫ?$ᢣ┐Ḅ?$Z{public:QB(){cout«"B::-B0i/called.

287"©ª<ᵨ?$᪆᪀ᦪvoidmainO{A*Ap=newB;B*Bp2=newB;cout«"deleteobject:

288";deleteAp;cout«”delegsecondobject:

289";deleteBp2;)

290ᐸ³᱄$ᢣ┐9($ᢣ┐Ḅ´µ1)¶·1dᢣ┐¸s"¹ᦪ6$8C++$ZḄᢣ┐P++/-,ºᯠᵨ஺2)ᢣ┐W§ᢥ᯿ᢣ┐ᡠᢣḄ$8&'Ḅ஺P++¿=Áp=p+l//p=(unsignedint)basep+sizeof(*p)´µ஺3)Âd᱄$p++A($p++´µR![R⌕ÃÄR⌕ᵨ᱄$ᢣ┐++ÆÇÈÉᦪÊ஺4.3᝱ᳮËÌᳮÍÎd>v$%JKᦪᘤoᙠ$%?ᡂ"#ᦪ⊤>ᦪ⊤"#ÏÐ$ᡂᕒᦪᢣ┐Ḅᦪ6Â᪀>ᦪ⊤ᵫᘤÑ«?ᡂAÒÓḄ>virtualᡂᕒᦪo/ᘤÔᐭᦪ⊤%>vÏᙠᦪ#Z%ᨵ"#ᢣᔣᦪ⊤Ḅᢣ┐(C++ᘤ×᱄$Zஹ($ZØÙÚÛvptrᢣ┐[v&'howToPrint(Parent*base)ᦪC++ᘤR◤⌕Ýᑖ($Zᡈὅ᱄$Zs◤⌕ábaseᢣ┐%rvptrᢣ┐ᓽ஺)

291>VPTR"ãÉn$ZḄä"#ᡂᕒ4.3.1᝱ḄᳮC++%᝱Ḅᳮv$%JKᦪᘤoᙠ$%?ᡂ"#ᦪ⊤ᦪ⊤"#ÏÐ$ᡂᕒᦪᢣ┐Ḅᦪ6Â᪀ᦪ⊤ᵫᘤÑ«?ᡂAÒÓḄvirtualᡂᕒᦪo/ᘤÔᐭᦪ⊤%Ïᙠᦪ#Z%ᨵ"#ᢣᔣᦪ⊤Ḅᢣ┐(vptrᢣ┐)classParent(public:virtualuoidFunc()VTABLEvoidParent::func()virtualuoidFunc(inti)åvoidChild::func()virtualuoidFunc(inti)(cout<<*'Child::func(inti),B<

292uoidrun(Parent*p)pVPTR-------->VTABLEp->Func();voidParent::func()voidParent::func(inti)æK1:çᦪ⊤ᢣ┐VPTR<ᵨᑏᦪᙠèW'&'Ḅm]◤⌕çqᙬÈÉêMª;ë©ì<ᵨḄᦪ஺íîçᡂᕒᦪᙠïª;|<ᵨḄᦪ஺ᙠᦔ᳛òᦪḄᦔ᳛⌕óô஺æK2dz@ᦔ᳛ὃ⇋°ᨵ⌕.ᡠᨵᡂᕒᦪJKnᦪæK3:C++ᘤ᡻'HowToPrintᦪR◤⌕Ýᑖ($Zø᱄$Z

293ParentvirtualParentpl;4/UVWXYZ[Childcl;howToPrint(ftpl),howToPrint(&cl)cout«*hello.*«endl,system("pause").return.virtualbase-\]p$^_ᘤᙠbcᙢe⌕gVWhᢝjᩭ᱄l᡻E᱄lḄ+ᦪ(jᩭl᡻ElḄ+ᦪ3%&'⊇ᗩ*+,-.*┿0:23456+78*9:;<=>•@ᡈὅ᱄=>D2᝞opqr+ᦪst᪷.v.ᙠ☟᝱ὶzḄF{|}~⌕)ᵨḄ+ᦪ஺4.3.2᝞GHIvptrᢣ┐ḄMᙠ#includeusingnamespacestd;classA(public:voidprintf()cout<

294};classB(public:virtualvoidprintf()(cout<

295஻Tsizeof(A),sizeof(B));cout«*hello...*«endl;system("pause");return;)

29643.3᪀⌼hᦪp9qᵨghᦪTstu᝱ᔩ1>xpḄVPTRᢣ┐yz{᎛}~ᓄ?>xᙠḄ{Tᵫ_`ᘤ>VPTRᢣ┐~ᓄᨵ>xḄ᪀⌼ᐰVPTRḄᢣᔣᨬ᱄=>xḄVPTRᢣᔣ᱄=ghᦪ⊤<=>xḄVPTRᢣᔣ<=ghᦪ⊤2ᑖ᪆ᑖ᪆᱄+ᦪ⊤2᡻E᱄Ḅ᪀⌼+ᦪḄFcl.vptrᢣᔣ᱄Ḅ+ᦪ⊤᱄Ḅ᪀⌼+ᦪEel.vptrᢣᔣḄ+ᦪ⊤3?Ḅcl.vptrᢣ┐ᑖᡂ===l᪀⌼Fᙠ᱄Ḅ᪀⌼+ᦪ)ᵨ+ᦪI᝱.

2975ஹghᦪx=5.1ᭆ¢+ᦪl+ᦪpcᙠCḄ+ᦪᙠᨵ~K⌕~KḄ᱐+ᦪᔜX¢cᐳ¤☢t¦Ḅ§¨©ªஹ¬Ḅ®ᙽ°Hᑜᑖ+ᦪC²virtualᦪ³ᦪ⊤=0;“cᐹᨵ+ᦪḄl஺classpoint{/*.......*/};classshape஻{pointcenter;public:pointwhere(){retiuncenter;}voidmove(pointp){enter=p;draw();}virtualvoidrotate(int)=0;஻ᦪvirtualvoiddra^v()=0;஻ᦪ}$shapex;//error,shape*p;//ok,Ḅᢣ┐shapef();//error,!"#$voidg(shape);//error,!"%ᦪshape&h(shape&);//ok,Ḅ&ᵨ

298classclassshape$//XY?{pointcenter;£public:⌕abcircleᡂ¶lpointwhere(){reninfc?·¸0¹ºC£voidmove(pointp/{enclassabcircle:publicshapete()virtualvoidrotate(int{intradius;virtualvoiddraw()=0};/public:voidrotate(int);voiddraw();classabcircle:public)({intradius:»X¢abcircle::draw()public:voidrotate(int)abcircle::rotate(int)Ḅ~K)(5.2x=ᫀ¦classfigureqᓫ?{protected:doublex.y;public:voidset_dim(doublei.doublej=0){x=i;y=j:}virtualvoidshowareaO=0;஻3ᦪ}$classtriangle:publicfigure{public:void{cout«<'*TVia»glewithbi§andbase«'*hasanareaM”};)classsquare:publicfigure{public:voidshowareaO(couf«MSquairewithdimension**<

299#include//figure.h#include2figm-e.h,'classfigure{protected:doublex.y;voidmainOpublic:voidset_dim(doublei.double{figure*p;//noXY?ᢣ┐virtualvoidshowareaOtrianglet;)squares;classtriangle:publicfigureckclec;{public:P=&t;voidp->$et__dim(10.0£5.0)$//triangle::setjdim(){withhiglp->show_area();p=&s;classsquare:publicfigurep->set_dim(l0.05.0);//square::sgtjHni(){public:rp->show_area();vt»idshowareaO{co»iF«*'Squar«withdinp=&c;}p->set_dim(9.0);//circle::setjdim()classcircle:publicfigurep->show_areaO£{public:voidshowareaO{couK<**CirctewcouKv”hasana});5.3x=ᙠu²³pḄ´ᵨC++pµᨵJavapḄ¶·ᭆ¢Tx=¸¹º»JavapḄ¶·=஺¼¶·½¾¿5.3.1ᨵᐵu²³ḄÀIÁZḄu²³}s▭ÃÄÅÆÇÈḄu²³ÁÃÄpÉÊËÌZḄu²³ÍÎÏÐ}ÑᵨḄuÒ²³ÓᩭḄÕṹ×ᩖឋÚuÛᐸÓᩭḄÝᑭuÒ²³>ÕṹßàឋZḄáâÍãäឋḄᙠåæçèZTéGu²³ê¸¹ᵨᓫ²³Õìu²³pḄíÌឋu²³Ð9îïḄð⚪

300□fe¼½H¾¿¼J½ᨚFÁ¾¿5.3.2u²³Ḅ´ᵨòóC++pÍᔲᨵJavapḄ¶·ᭆ¢õöᜧuᦪ☢ᔣ>xùúêÐûᢝu²³öᜧuᦪ☢ᔣ>xùúêûᢝ¶·Ḅᭆ¢C++pµᨵ¶·Ḅᭆ¢C++p¸¹Ñᵨghᦪst¶·¶·=pᨵhᦪýþÌTµᨵéGᦪÿḄ஺classInterface(public:virtualvoidfuncl()=0;virtualvoidfunc2(inti)=0;virtualvoidfunc3(inti)=0;▭ᩭឋᩖឋ⚪!"#$%&ᵨᓫᩭ)*

301+,-./01234-015஺6+◤⌕᪷:012015஺include"iostream"usingnamespacestd;/*C++;<ᨵḄᭆ?C++;@ᵨABCᦪ5+;,ᨵCᦪEF3<ᨵGHᦪ:Ḅ஺*/classInterfacel(public:virtualvoidprint()=0;virtualintaddfinta,intb)=0;classInterface2(public:virtualvoidprint()=0;virtualintadd(inta,intb)=0;virtualintminus(inta,intb)=0;

302);classparent(public:inta;)classChild:publicparent,publicInterfacel,publicInterface2(public:voidprint()(cout«HChild::print"«endl;}intadd(inta,intb){returna+b;)intminus(inta,intb)returna-b;)

303);intmain()(Childc;c.print();cout<add(7,8)«endl;cout«i2->add(7,8)«endl;system("pause");5.4JK+LMNOᓄQᑏ./C++S3&TSᕒ(programmer)W1⌕X1&TYZ[Sᕒ(junior_programmer);[Sᕒ(mid_programmer)\[Sᕒ(adv_programmer)ḄW2⌕XᑭᵨJK+^._☢3abSḄ᡽d3e᝞:hi3&Tj᪀l(architect)ḄW

304*/5.5☢ᔣJK+QopOᓄᳮrLMsBCᦪ᝱ឋ@ᡂᕒCᦪ᪷:vᵨwKḄ+FxyzḄ{|s᝱ឋᱯ~〉ᔠ5ᑖ᪀Ḅ^3bw⚪JKᐳឋ35~s☢ᔣJK+Q☢ᔣQ-⚗;⌕ᢈ1.஺5.4.1ᫀsocketC++F%&5^᪾jᡂaxᫀ¡¢.£Ḅ^¤ᨵᡂ¥Ḅ᪾j஺᪾j.£y¦ᓄ31§ᵫḄᡂaᔆᖪḄx஺ᫀ◤X«¬ᙠ^᪾j;ᡂaᔆᖪḄSocket!xaᔆᖪ®¯x஺aᔆᖪḄSocket!x°ᡂ±N²Ḅ!aᔆᖪ®¯x°ᡂᦪ:〈®¯ᦪ:´¯´¯஺

305ᫀ⌕X1)1µᢝ/ᔆᖪḄSocket!xᐭ¸2)1µᢝ/aᔆᖪ®¯xḄᐭ¸3)^᪾j¹᧕y᪾j◤X5oὃ1^᪾jஹax᝞Hᑖoὃ2^᪾j3᝞H§ᵫᡂax(%&ᙽ⌕X¾ஹ⌕X¿)oὃ3ᑖᡂÁ3^᪾jḄSᕒ3ÂÃÄÅÆÇaxᐭ¸ÂÃÄÅÆÇQṹ5ᑖ᪆ᨵÊ/+CSocketProtocolCSckFactorylmplCSckFactorylmp2CEncDesProtocolHwEncdesciscoEncdes1ஹCSocketProtocolJK+2ஹQᑏ᪾jCᦪ3ஹQᑏ᪾jËÌCᦪ4ஹᔆᖪ1(CSckFactorylmpl)5CSocketProtocolஹᔆᖪ2(CSckFactorylmpl)5CSocketProtoco5ஹJK®¯(CEncDesProtocol)ஹ®¯ᔆᖪ1(CHwImp)ஹ®¯ᔆᖪ2(CCiscoImp)),ᡂ5ÍF6ஹ᪾j(cÎÏCᦪaÐ3᪾jCᦪC+++aÐ3᪾j+)Ñ/⌕Ḅ☢ᔣwKop-Óᔠ(OÔ)Õᐭ

306ÖᑴØÙIOCMVC☢ᔣwKop᡽daopopaopop-wQopḄᨵÚḄ⊡ᐙ5.4.2ᫀ&TᕒW5.4.3ᫀ&TÑHÝḄ⊤☢ßÝß5.6C☢ᔣQC᝱àáâãäᜩæᑁè3é®êëᡊ3íîÎïop¤ðñ3«òᕒ¿óoô஺æÁ®Oõör,⌕¬{÷3øùè᧕ö5.6.1Cᦪ+FÎïúẠCᦪ⌕üýþஹÿᦪஹcḄᦪᨵᱯḄCtypedefᦪtypedeftypename(parameterlist)typedefintf(int,int);typedefvoidp(int);ᦪᢣ┐ᦪᢣ┐ᵨᢣᔣᦪ

307ᦪᦪḄᐭ"ᙢᙬ1)%ᦪ&ᦪᢣ┐:FuncType*pointer;2)(%)*+&,type(*pointer)(parameterlist);pointerᦪᢣ┐-.typeᢣᔣᦪḄparameterlistᢣᔣᦪḄ/ᦪᑡ⊤ᦪᢣ┐23ᳮ஻ᦪ஻ᦪᢣ┐஻ᦪᢣ┐-.ᦪ6ᢣ┐23ᳮ஻ᦪ62஻ᦪ6ᢣ┐஻ᦪ6ᢣ┐-.typedefint(FUNC)(int);inttest(inti)(returni*i;)

308voidf()(printf("Callf()...

309");}intmain()(FUNC*pt=test;void(*pf)()=&f;pf();(*pf)();printf("Functionpointercall:%d

310",pt(3));5.6.2ᦪᢣ┐7ᦪ/ᦪ1ஹᢣ┐7ᦪ/ᦪpkᦪᢣ┐7ᦪ/ᦪ8ᢣ┐7ᦪ/ᦪ9ᢣ┐7ᦪ/ᦪஹ:9஺஺஺<=92ஹᦪᢣ┐7ᦪ/ᦪ>ᦪᢣ┐7ᦪḄ/ᦪ?@⌴BCDᵨᦪ,CDᵨᦪF%)Gᢣ┐Dᵨ᜜IḄᦪ?GFJᡂLD

3113ஹMNintadd(inta,intb);intlibfun(int(*pDis)(inta,intb));intmain(void)(int(*pfun)(inta,intb);pfun=add;libfun(pfun);intadd(inta,intb)(returna+b;intlibfun(int(*pDis)(inta,intb))(inta,b;a=1Ob=2;add(l,3)஻*+Dᵨaddᦪ

312printf("%d",pDis(a,b));஻ᦪᢣ┐7ᦪ/ᦪ?P+Dᵨaddᦪ஻QὃG᪵ᑏpDisfa,b)ᨵUVWᜐY)஻ᒈ᪆Q\஻:LᦪḄDᵨ]ᦪḄ^_ᨵᦔḄᑖb஻2C++Ḅc᝱?%᡽f_ᙠGhᦪᙠiᦻk>Ꮇ᝞intlibfun(int(*pDis)(inta,intb))nḄᦪ?FoᨵpᵨDL?ᦪᢣ┐/ᦪq᜜Iᦪᙢᙬ@ᐭᩭ^_DᵨᦪaddḄsṹuLvᦋ?(xyᦋznḄsṹ?F%){|^_Dᵨ}~Ḅ]ᓣ9DᦪQ:

313+ᦪᢣ┐ÃÄᑮḄ0ᵨ+ᦪḄ³ᦪஹ+ᦪÅÆÇXYÈ~,DᦪḄ,7LḄᦪḄ/ᦪஹᦪQὃ•,CᘤᐹḄ2?^_὚ᔠḄYC++ᘤc᝱Ḅᑴvptrᢣ┐]ᦪ⊤?ᦪᐭ"ᙢᙬᩭ^_5.6.3ᦪᢣ┐{ᔣDᵨ1ஹᦪᢣ┐7ᦪ/ᦪ?Dᵨ¡CDᵨᦪ]¢Dᦪᙠiᦻkᵨᩭᦟ¤?¥ᨵ¦§¨&2ஹᦪᢣ┐7ᦪ/ᦪCDᵨᦪ]¢Dᦪxᙠiᦻkஹ©ᙽ஺«¬,ᳮCDᵨᦪUVᑴCDᵨᩭḄ஺᪾¯᪾¯°±LCDᵨᦪḄᐭ"᪾¯²L³=©ᙽᐭ"ᙢᙬḄ´ᡂµ¶᪾¯ᐹᜓDᵨ³=©ᙽᐭ"ᦪ3ஹMNtypedefint*EncDataFuncunsignedchar*inData,intinDataLen,unsignedchar*outData,int

314*outDataLen,void*Ref,intRefLen);intMyEncDataFunc(unsignedchar*inDataJntinDataLen,unsignedchar*outData,int*outDataLen,void*Ref,intRefLen)(intrv=0;char*p="222222222222";strcpy(outData,p);*outDataLen=strlen(p);returnrv;)intSend_Data(EncDataFuncencDataFunc,unsignedchar*inData,intinDataLen,unsignedchar*outData,int*outDatalen)(intrv=0;if(encDataFunc!=NULL)(rv=encDataFunc(inData,inDataLen,outData,outDatalen,NULL,0);if(rv!=0)(printf("funcencDataFunc()err.

315H);returnrv;)

316)returnrv;)intmain()(intrv=0;EncDataFuncencDataFunc=NULL;encDataFunc=MyEncDataFunc;//³Dᵨ{unsignedcharinData[2048];intinDataLen;unsignedcharoutData[2048];intoutDatalen;strcpy(inData"1111");zinDataLen=strlen(inData);rv=encDataFunc(inData,inDataLen,outData,&outDatalen,NULL,0);if(rv!=0)(printf("edferr..…

317");}

318elseprintf("edfok

319");printf("%s

320",outData);)}(unsignedcharinData[2048];intinDataLen;unsignedcharoutData[2048];intoutDatalen;strcpy(inData,"3333");inDataLen=strlen(inData);rv=Send_Data(MyEncDataFuncinData,inDataLen,outData,&outDatalen);zif(rv!=0)(printf("funcSend_Dataerr:%d",rv);returnrv;)printf("%s

321",outData);)getchar();

3225.6.4ᦪᢣ┐¹ᔣDᵨDᦪᦔºf»஺5.6.5.Cz᝱nᓣ9ᡂ᪾¯ᫀ½C᱐Socketz᝱nᓣ9ᡂ᪾¯´ᡂ³=¿ÀÁÂ,Cz᝱nᓣ9ᡂ᪾¯ᫀ½ÃÄz᝱n,ÅÆᝅ+"?ᓫÉÊËᡂ©ᙽ?²ÌÍDᵨOÎ2᡽f஺᪾¯,¶ᵫḄ᡽fᫀ½ÐÑ,ÒḄÓÔÕÖ×ØÙᨵᡂÚḄ᪾¯?%)ᨵCᑏ?(%)ᵫC++஺Ûk᪾¯ÒxÜÝ-ᓄ?¶ᵫḄ´ᡂ³=ᔆᖪḄ¿À஺ᫀ½◤â,ᙠsocketÕn?ãᡂᦪäå浶?ᨵnᔆᖪḄåæ¿À²ç⌱é?᝞§^_z᝱n]³=ᔆᖪ¿ÀḄ὚ᔠ஺⏨,C++ÅÆ?(F☢ᔣÅÆ~^_Ḅì>C++ᘤc᝱ᑴ?íîïWᵨL஺vptrᢣ┐ஹᦪ⊤ODᵨðñãᡂ஺?C᝞§^_òYᫀ½⌕â,1¶ôᢝc³=ᔆᖪåæ¿ÀḄᐭö2ÓÔÕÖ×Ø᪾¯x÷᧕ÜÝ᪾¯◤â^_Q\ᑖ᪆

323U᝱ÉDLLᓣËᡂ᪾ÍᫀÏÐÑ实现:行姬一1)可缓存第三方函数入口地址b᪵᪾Í|G¹rÓᢣ┐Ô+ᦪ³ᦪÆ)+ᦪJÕ᡻EᩭÖ×FØṹ¼ÚcᔆᖪḄØṹÝÞßà¾὚ᔠÝÞC++Ḅ᝱G᡽äᦔoæᙠ᪾Í~K+ᦪᢣ┐vçèXYᢣ~ᝅêët¦jìíᙢîQὃ1,ÓÔÕÖ×Ø᪾¯ஹ³=¿À᝞§ᑖùQὃ2,ÓÔÕÖ×Ø᪾¯?᝞§ᵫ´ᡂ³=¿ÀÛk°ú,©ᙽ⌕âûஹ+"⌕âüQὃ3,Ûkᑖùýþ?z᝱nÿᐭᔆᖪ᪾Ḅᕒᐭṹ"#1ஹ%᝱'()*+,-.ᡂ01Ḅ2ᵨtypedefint(*EncData)(unsignedchar*inData,intinDataLen,unsignedchar*outData,int*outDataLen,void*Ref,intRefLen);typedefint(*DecData)(unsignedchar*inData,intinDataLen,unsignedchar*outData,int*outDataLen,void*Ref,intRefLen);2ஹOPᔆᖪ.ᡂ+,QᦪḄᑏ3ஹTU2V஺4ஹ%᝱'(XYZQᦪḄᐭ[ᙢᙬ^X_YZ`a"#b஺

324ᫀdefg2QᦪhᑭᵨQᦪᢣ┐Qᦪlᦪ"#Ḅma2ᵨnᑴᐹq01Ḅ"#ὅX_s⍝u᎛w2ᵨ஺g2nᑴxᳮhzᐹq{|}u2ᵨὅ~Qᦪᢣ┐2ᵨᐹqQᦪg2nᑴḄ2ᵨὅw2Qᦪᑖ`ὅ_01Ḅ"#01Ḅ2ᵨX὚ᔠU[Ḅ5.6.6▬hḄ┶ᝯᑢᜓᑭᵨᕜஹᩔ¢▭¤¥¦§¨ᓭªஹₚ¬ஹ⋰□¯°±¨²³´µª஺ᕜ¶¶ᓝᑖ¸឴º»ᜐ½¾¿Àₚ¬஺_ÁᑢᜓÂᯠÄᏔᕜÆÇᩭTÉᩗËh"ÍḄÎÎÏÐஹÑÒᡃÔὶÖᢙØ*ᔣᑢᜓÚÛÜÝÞᩭᓭßàἭâÝÔãₚ¬ᩭᣚ஺”Éᩗᜧçèéêᑮₚ¬ËÛ஺ᑢᜓìíîïÞð¶⌕òóô⍝h"〈ö÷øùÆúû_üÍýþÿᔺᡃᨵ᣸ᒹᜫₚ஺”Ḽᨩᨩᐵ᯿⍝#"ᡃ%&ᨵ'(┶*ᑁ,'ᩩᝯ/஺ᑮᓭ23ᡭ567(ᑮ893ᡭ56:(ᓻញ=>3ᡭ56'(஺"67(┶*7ᑮᔺ?@ABCὁ6:(┶*ᑢᜓGHᩗJ/ᶇL?MNOPQRᜧTU᛻6'(┶*GᔺTWXY?ZH[\

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

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

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