亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? apa.htm

?? 21天學會VC的英文版
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
<STRONG>NOTE:</STRONG> It is always advisable to differentiate your global and local	variables by prefixing them with a g for global and l for local. <HR></BLOCKQUOTE><H2><A NAME="Heading5"></A>Pointers</H2><P>Pointers are one of the most important features of C++, and they are always confusingto new programmers of C++. Pointers work by providing access to the original datadirectly, which increases efficiency. Pointers primarily work with two operators,the indirection operator (*) and the address-of operator (&amp;). It is common practiceto add a p to the beginning of a pointer variable's name to distinguish it from othervariables. A pointer is just another variable, but the difference is it holds a memoryaddress. You declare a pointer by putting an asterisk (*) in front of the pointername. To access the address of the variable, you put the &amp; operator in frontof the variable name.</P><P>To understand pointers, you need a brief overview of how variables are stored.You covered different variable types in Table A.1. Table A.4 shows the size of thevariable types.</P><P><H4>TABLE A.4. VARIABLE TYPE SIZES.</H4><P><TABLE BORDER="1">	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT"><I>Variable Type</I></TD>		<TD ALIGN="LEFT"><I>Size in Bytes</I></TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">unsigned short int</TD>		<TD ALIGN="LEFT">2 bytes</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">short int</TD>		<TD ALIGN="LEFT">2 bytes</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">unsigned long int</TD>		<TD ALIGN="LEFT">4 bytes</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">long int</TD>		<TD ALIGN="LEFT">4 bytes</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">int</TD>		<TD ALIGN="LEFT">4 bytes (32 bit)</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">unsigned int</TD>		<TD ALIGN="LEFT">2 bytes(32 bit)</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">char</TD>		<TD ALIGN="LEFT">1 byte</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">float</TD>		<TD ALIGN="LEFT">4 bytes</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">double</TD>		<TD ALIGN="LEFT">8 bytes</TD>	</TR></TABLE></P><P>In the program address.cpp in Listing A.5, the two variables base and radius eachoccupy 8 and 4 bytes. Assume that your computer memory has a certain space to storethese variables, they are sequentially numbered from 1 through 12, and each spaceis 1 byte. When you declare the variable base of type double, it occupies 8 bytes.Assume these 8 bytes reside at locations beginning from 1 through 8. You also declaredanother variable radius of type int, which occupies 4 bytes and its location is byte9 through byte 12. The location of each of these variables is termed as its address.Hence, the variable base has an address beginning at address 1 and ending at address8. Similarly, the variable radius has an address beginning at address 9 and endingat address 12. When you use the address-of operator (&amp;) on a variable, this isthe address returned. The variable base has an address from 1 through 8, but theaddress-of operator returns its address as 1. Internally, the system already knowsthat the total addresses occupied are 8 because you defined its type as double.</P><BLOCKQUOTE>	<P><HR><STRONG>NOTE:</STRONG> The byte size shown in Table A.4 is not fixed. It can be different	depending on your compiler and the hardware on which it runs. To determine the size	of the variable for your individual compiler and hardware settings, use the sizeof()	function as implemented in Listing A.5 on lines 13 and 16. <HR></BLOCKQUOTE><P>The program in Listing A.5 shows how to access the memory address of variables.</P><P><H4>LISTING A.5. Address.cpp.</H4><PRE> 1: // Workspace:  Pointers 2: // Program name:  Address.cpp 3:  4: #include &lt;iostream.h&gt; 5:  6: double base = 5.0; 7: int radius = 2; 8:  9: void main()10: {11: cout&lt;&lt;&quot;The VALUE of base is: &quot;&lt;&lt;base&lt;&lt;endl;12: cout&lt;&lt;&quot;The ADDRESS of base is: &quot;&lt;&lt;&amp;base&lt;&lt;endl;13: cout&lt;&lt;&quot;The SIZE of double base is: &quot;&lt;&lt;sizeof(double)&lt;&lt; &quot;bytes \n&quot;;14: cout&lt;&lt;&quot;The VALUE of radius is: &quot;&lt;&lt;radius&lt;&lt;endl;15: cout&lt;&lt;&quot;The ADDRESS of radius is: &quot;&lt;&lt;&amp;radius&lt;&lt;endl;16: cout&lt;&lt;&quot;The SIZE of integer radius is: &quot;&lt;&lt;sizeof(int)&lt;&lt;&quot; bytes \n&quot;;17: }</PRE><P>The address of the variables is accessed directly on lines 12 and 15 by usingthe address-of operator (&amp;).The addresses of the variables base and radius areshown in Figure A.8. The addresses of the variables depend on your system, so theymight not be the same.</P><P><A HREF="javascript:popUp('0afig08.gif')"><B>FIGURE A.8.</B></A><B> </B><I>Usingthe address-of operator.</I></P><P>The indirection operator (*) operates by providing access to the value storedin the address of the variable. When a pointer is declared for a specific variabletype (such as int), it should not be used with any other type unless it is recastto a new type. You should remember that a pointer is a variable, and like all othervariables, it should be declared and initialized. A pointer that is not initializedcould be dangerous. The program in Listing A.5 is modified to access the values ofthe variables radius and base. The modified program is provided in Listing A.6.</P><P><H4>LISTING A.6. Address.cpp.</H4><PRE> 1: // Workspace:  Pointers</PRE><PRE> 2: // Program name:  Address.cpp 3:  4: #include &lt;iostream.h&gt; 5:  6: double base =5.0; 7: int radius =2; 8:  9: double *pBase =0;           // Initialize the pointer variable10: int *pRadius =0;            // Initialize the pointer variable11: 12: void main()13: {14: pBase = &amp;base;                   // Assign the address of base15: pRadius = &amp;radius;               // Assign the address of radius16: cout&lt;&lt;&quot;The VALUE of base is: &quot;&lt;&lt;base&lt;&lt;endl;    // Output value of base17: cout&lt;&lt;&quot;The ADDRESS of base is: &quot;&lt;&lt;&amp;base&lt;&lt;endl; // Output address of           &Acirc;base18: cout&lt;&lt;&quot;The SIZE of double base is: &quot;&lt;&lt;sizeof(double)&lt;&lt; &quot;bytes \n 19: cout&lt;&lt;&quot;The VALUE of pBase is: &quot;&lt;&lt;*pBase&lt;&lt;endl;  	            &Acirc; // Output redirected value of base20: 21: cout&lt;&lt;&quot;The VALUE of radius is: &quot;&lt;&lt;radius&lt;&lt;endl;     	            &Acirc;// Output value of radius22: cout&lt;&lt;&quot;The ADDRESS of radius is: &quot;&lt;&lt;&amp;radius&lt;&lt;endl;   	            &Acirc;// Output address of base23: cout&lt;&lt;&quot;The SIZE of integer radius is: &quot;&lt;&lt;sizeof(int)&lt;&lt;&quot; bytes \n&quot;; 24: cout&lt;&lt;&quot;The VALUE of pRadius is: &quot;&lt;&lt;*pRadius&lt;&lt;endl;  	            &Acirc;// Output redirected value of radius25: 26: }</PRE><H3><A NAME="Heading6"></A>References</H3><P>An important feature in C++ that is used often with function parameters is <I>references</I>.Reference is simply a synonym for variable. Until now, you have passed parametersin functions by value. You will learn how to pass parameters by reference. You createa reference variable by specifying its type and preceding the name with the referenceoperator (&amp;). If you have a variable float radius, you create a reference with</P><P><PRE>void functionname (float &amp;rfradius);</PRE><P>You can give the reference variable any name you want; in the following example,the reference variable names have an rf prefix. The advantage of a reference is thatyou can pass it as a parameter, like any other variable. However, unlike regularparameters, changes made to the reference's value while in a function are storedin the original variable. The example in Listing A.7 shows how the reference changesthe value of the variable in the main() function.</P><P><H4>LISTING A.7. Refer.cpp.</H4><PRE> 1: // Workspace:  Reference 2: // Program name:  Refer.cpp 3:  4: #include &lt;iostream.h&gt; 5:  6: void squareit (float &amp;num); 7: int main() 8:  9: {10: float num=5.0;11: 12: cout&lt;&lt;&quot;In Main: before squaring number: &quot;&lt;&lt;num*num&lt;&lt;&quot;\n&quot;;13: 14: squareit (num);15: cout&lt;&lt;&quot;In Main: after squaring number: &quot;&lt;&lt;num*num&lt;&lt;&quot;\n&quot;;16: return 0;17: 18: }19: 20: void  squareit (float &amp;rfnum)21: {22: 23: cout&lt;&lt;&quot;In Squareit: before squaring number: &quot;&lt;&lt;rfnum*rfnum&lt;&lt;&quot;\n&quot;;24: 25: rfnum = rfnum+5;26: 27: cout&lt;&lt;&quot;In Squareit: after squaring number: &quot;&lt;&lt;rfnum*rfnum&lt;&lt;&quot;\n&quot;;28: 29: }</PRE><P>You define a function squareit on line 6, and its parameters are references. Thisis the function prototype. On line 10, the variable num is given a value of 5. Thesquare of the number is displayed to the screen on line 15. On line 14, you callthe squareit function.</P><BLOCKQUOTE>	<P><HR><STRONG>NOTE:</STRONG> You pass the variable num and not its address. <HR></BLOCKQUOTE><P>Only when execution jumps to line 20 from line 14 are the variables identifiedas references. On line 27, the references are squared and displayed. They shouldbe the same as the variables because they are just like aliases for the variables.On line 25, you add 5 to the reference, which in turn changes the variable num. Theincremented value is squared and displayed to the screen. Execution returns to main()on line 15, where the display confirms the variable was changed. The output for thisprogram is shown in Figure A.9.</P><P><A HREF="javascript:popUp('0afig09.gif')"><B>FIGURE A.9.</B></A><B> </B><I>Passingparameters by reference.</I><DL>	<P></DL><H2><A NAME="Heading7"></A>Classes</H2><P>In the previous sections, you used data types (int, float, and so on) that areinherently built into C++. In large complex programs, it is easier to define yourown type, which could be a combination of the inherent types. Classes were addedto C++ primarily for this purpose--to enable the programmer to be able to definecustom data types and methods. The concept of classes in C++ evolved due to certainlimitations of the concept of structures in C. To thoroughly understand classes,you have to step back into C and understand structures first.</P><P>A structure in C/C++ is a way of representing your own custom data. When you definedvariables, you first defined their data types, followed by their names:</P><P><PRE>int radius;</PRE><P>To define your own data types, you use the keyword struct. The syntax for declaringa structure is</P><P><PRE><I>struct</I> [<I>structure_name</I>]  {  <I>data_members</I>  }</PRE><P>The <I>data_members</I> of a structure are variables and functions. When functionsare associated with classes, they are more appropriately referred to as methods.From now on, you use the term function for program code that is not a part of a structureor class. A reference to methods indicates that the function is associated with aclass structure. To understand how structures are used, review the example in ListingA.8.</P><P><H4>LISTING A.8. Struct.cpp.</H4><PRE> 1: // Workspace Name: Class1 2: // Program Name:  Struct.cpp 3: #include &lt;iostream.h&gt; 4:  5: struct farm_house  6: { 7: int pig_values; 8: }; 9: 10: int main()11: {12: farm_house pig1, pig2, pig3;13: 14: pig1.pig_values = 12;15: pig2.pig_values = 13;16: pig3.pig_values = 14;17: 18: cout &lt;&lt; &quot;The value of pig1 is &quot; &lt;&lt; pig1.pig_values&lt;&lt; &quot;\n&quot;;19: cout &lt;&lt; &quot;The value of pig2 is &quot; &lt;&lt; pig2.pig_values &lt;&lt; &quot;\n&quot;;20: cout &lt;&lt; &quot;The value of pig3 is &quot; &lt;&lt; pig3.pig_values &lt;&lt; &quot;\n&quot;;21:  22: return 0;23: }.</PRE><P>On line 5, the struct keyword is followed by the name of the structure. The actualdefinition of the structure is enclosed in the curly brackets. This particular structuredefines a data member of type int and name pig_value. If you remember, I mentionedearlier that when you define a structure, you basically define a custom-made datatype. All data types end with a semicolon, so the structure should also end witha semicolon. On line 12, you define three instances of the same type of farm_house,each of which contains a single int type variable.</P><BLOCKQUOTE>	<P><HR><STRONG>NOTE:</STRONG> If you strictly use C, then to define instances on line 12,	you must use the keyword struct:</P>	<PRE>struct farm_house pig1, pig2, pig3;</PRE></BLOCKQUOTE><PRE></PRE><BLOCKQUOTE>	<P>This is no longer required in C++. <HR></BLOCKQUOTE><P>On lines 14 through 16, you assign values to the member variables of each structure.The structure member operator (.), also called the dot operator, is used to accessmember variables of the structure. On lines 18 through 20, the assigned values areoutput to the screen. Figure A.10 shows the output from this program.</P><P><A HREF="javascript:popUp('0afig10.gif')"><B>FIGURE A.10.</B></A><B> </B><I>Structureoutput.</I></P><P>The most important concept of object-oriented programming is encapsulation. Encapsulationcan involve one or more classes. Encapsulation promotes safeguards and data hiding.The struct.cpp program had no encapsulation or classes. What do encapsulation andclasses mean in object-oriented programming?</P>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美激情一区二区在线| 成人激情免费视频| 欧美老肥妇做.爰bbww| 综合久久给合久久狠狠狠97色| 极品少妇xxxx精品少妇| 久久精品人人做| 国产一区91精品张津瑜| 国产精品每日更新| 成人高清免费在线播放| 亚洲欧美精品午睡沙发| 色又黄又爽网站www久久| 亚洲黄色av一区| 欧美精品在线一区二区三区| 日本不卡一二三区黄网| 欧美精品一区二区三区蜜臀| 激情综合五月天| 国产精品每日更新| 91搞黄在线观看| 一区二区三区小说| 在线综合亚洲欧美在线视频| 国产毛片精品国产一区二区三区| 国产精品久久久久久久久久久免费看 | 亚洲激情五月婷婷| 欧美视频中文字幕| 蜜臀久久久久久久| 中文字幕一区二区三区在线播放| av一区二区不卡| 亚洲品质自拍视频| 精品久久国产老人久久综合| 国产乱子伦一区二区三区国色天香| 国产精品私人自拍| 三级欧美在线一区| 欧美日韩综合在线| 午夜激情综合网| 久久久综合九色合综国产精品| 亚洲精品中文在线影院| 欧洲精品中文字幕| 欧美一级免费观看| 亚洲午夜视频在线| 国产精品一二三四| 亚洲精品在线观看网站| 五月综合激情日本mⅴ| 国产成人亚洲综合色影视| 91麻豆免费看| 欧美日韩精品专区| 日韩一区二区三区电影在线观看| 欧美日韩高清一区| 国产精品久久久久久久久久久免费看| 蜜臀99久久精品久久久久久软件| 国产亚洲精品aa午夜观看| 国产成人免费av在线| 国产欧美一区二区三区沐欲| 亚洲在线视频一区| 福利一区二区在线| 精品999在线播放| 视频一区视频二区中文| 一本色道亚洲精品aⅴ| 欧美激情在线一区二区三区| 老色鬼精品视频在线观看播放| 色狠狠一区二区三区香蕉| 日韩欧美国产三级电影视频| 亚洲一区在线观看免费观看电影高清| 成人免费视频视频| 日本一区二区不卡视频| 国产精品99久| 国产日韩欧美激情| 处破女av一区二区| 欧美国产禁国产网站cc| 丁香婷婷综合色啪| 中文字幕日韩av资源站| 国产99久久精品| 一区二区三区在线观看国产| 欧美视频精品在线观看| 国产一区二区三区在线观看免费| 美女任你摸久久| www精品美女久久久tv| 色国产综合视频| 成人黄色在线网站| 日韩va亚洲va欧美va久久| 国产成人av福利| 国产精品久久久久久久久免费桃花 | 日韩免费高清视频| 性做久久久久久久久| 一区二区三区四区不卡在线| 国产精品久久久久天堂| 中文字幕一区二区三区不卡| 国产欧美日韩精品a在线观看| 久久久综合精品| 亚洲裸体xxx| 91福利在线观看| 蜜桃精品视频在线| 亚洲国产精品人人做人人爽| 国产午夜久久久久| 在线观看日韩电影| 国产xxx精品视频大全| 偷拍亚洲欧洲综合| 国产亚洲欧美色| 日韩不卡在线观看日韩不卡视频| 国产99久久久国产精品潘金网站| 日本电影亚洲天堂一区| 国产亚洲午夜高清国产拍精品 | 一区二区三区精品在线观看| 日本视频一区二区三区| 色综合久久久久网| 欧美视频在线一区| 中文字幕一区三区| 国产91露脸合集magnet| 日韩免费福利电影在线观看| 玉米视频成人免费看| 国产福利精品一区| 国产成人午夜精品影院观看视频| 蜜桃av一区二区三区电影| 爽爽淫人综合网网站| 亚洲精品成人天堂一二三| 国产精品久久久久永久免费观看| 亚洲无人区一区| 一区二区在线观看视频 | 制服丝袜激情欧洲亚洲| 欧美美女一区二区在线观看| 久久久国产一区二区三区四区小说 | 亚洲欧美日韩国产中文在线| 亚洲欧美激情在线| 日韩精品一二区| 国产福利不卡视频| 7777精品伊人久久久大香线蕉的| xvideos.蜜桃一区二区| 久久久久久久一区| 亚洲一区二区视频在线观看| 久久福利视频一区二区| 成人一区二区三区| 欧美影院午夜播放| 久久久电影一区二区三区| 亚洲精品国产精华液| 国产呦精品一区二区三区网站| 99国产欧美另类久久久精品| 2023国产精品自拍| 亚洲三级在线看| 国v精品久久久网| 日韩一区二区麻豆国产| 久久噜噜亚洲综合| 琪琪久久久久日韩精品| 99久久伊人久久99| 精品国产凹凸成av人导航| 亚洲欧美国产高清| 东方欧美亚洲色图在线| 在线综合亚洲欧美在线视频| 樱花草国产18久久久久| 国产精品一级二级三级| 欧美综合色免费| 国产精品激情偷乱一区二区∴| 性做久久久久久| 欧美色爱综合网| 国产精品成人免费精品自在线观看 | proumb性欧美在线观看| 日韩欧美一区在线| 日韩成人免费电影| 色伊人久久综合中文字幕| 欧美草草影院在线视频| 亚洲国产一区二区视频| 99re66热这里只有精品3直播| 国产精品久久久久永久免费观看| 韩国av一区二区三区四区| 日韩欧美一区在线| 日韩国产精品91| 欧美一级免费大片| 婷婷丁香久久五月婷婷| 91精品国产麻豆国产自产在线 | 91蜜桃视频在线| 国产精品美日韩| kk眼镜猥琐国模调教系列一区二区| 久久综合久久综合亚洲| 午夜一区二区三区在线观看| 91免费看片在线观看| 久久婷婷成人综合色| 狠狠久久亚洲欧美| 精品成人一区二区| 国产在线精品免费| 久久久久久亚洲综合| 国产精品亚洲成人| 国产亚洲短视频| 97久久超碰国产精品电影| 最新国产精品久久精品| 国产二区国产一区在线观看| 欧美国产禁国产网站cc| 成人av资源下载| 亚洲一区在线观看免费观看电影高清| 色婷婷综合久久久| 免费观看91视频大全| 亚洲精品在线电影| 91一区二区在线观看| 亚洲欧美日韩久久| 91精品国产麻豆国产自产在线 | 久久精品二区亚洲w码| 欧美tk丨vk视频| 久久成人18免费观看| 欧美韩日一区二区三区四区| 不卡的av网站| 午夜激情一区二区三区| 精品国产一区二区精华| 99久久国产综合精品色伊 |