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

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

?? ch17.htm

?? good book for learning c++ standard language
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>

<HEAD>
<!-- This document was created from RTF source by rtftohtml version 3.0.1 -->

	<META NAME="GENERATOR" Content="Symantec Visual Page 1.0">
	<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1">
	<TITLE>Teach Yourself C++ in 21 Days</TITLE>
</HEAD>

<BODY TEXT="#000000" BGCOLOR="#FFFFFF">

<H1 ALIGN="CENTER"><A HREF="ch16.htm" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/htm/ch16.htm"><IMG SRC="../buttons/BLANPREV.GIF" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/buttons/BLANPREV.GIF"
WIDTH="37" HEIGHT="37" ALIGN="BOTTOM" BORDER="0"></A><A HREF="javascript:if(confirm('http://www.mcp.com/sams  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://www.mcp.com/sams'" tppabs="http://www.mcp.com/sams"><IMG
SRC="../buttons/BLANHOME.GIF" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/buttons/BLANHOME.GIF" WIDTH="37" HEIGHT="37" ALIGN="BOTTOM"
BORDER="0"></A><A HREF="../index.htm" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/index.htm"><IMG SRC="../buttons/BLANTOC.GIF" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/buttons/BLANTOC.GIF"
WIDTH="37" HEIGHT="37" ALIGN="BOTTOM" BORDER="0"></A><A HREF="ch18.htm" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/htm/ch18.htm"><IMG SRC="../buttons/BLANNEXT.GIF" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/buttons/BLANNEXT.GIF"
WIDTH="37" HEIGHT="37" ALIGN="BOTTOM" BORDER="0"></A></H1>
<H1></H1>

<UL>
	<LI><A HREF="#Heading1">Day 17</A>
	<UL>
		<LI><A HREF="#Heading2">The Preprocessor</A>
		<UL>
			<LI><A HREF="#Heading3">The Preprocessor and the Compiler</A>
			<LI><A HREF="#Heading4">Seeing the Intermediate Form</A>
			<LI><A HREF="#Heading5">Using #define</A>
			<UL>
				<LI><A HREF="#Heading6">Using #define for Constants</A>
				<LI><A HREF="#Heading7">Using #define for Tests</A>
				<LI><A HREF="#Heading8">The #else Precompiler Command</A>
			</UL>
			<LI><A HREF="#Heading9">Listing 17.1. Using #define.</A>
			<LI><A HREF="#Heading10">Inclusion and Inclusion Guards</A>
			<UL>
				<LI><A HREF="#Heading11">Defining on the Command Line</A>
				<LI><A HREF="#Heading12">Undefining</A>
			</UL>
			<LI><A HREF="#Heading13">Listing 17.2. Using #undef</A><A HREF="#Heading14">.</A>
			<UL>
				<LI><A HREF="#Heading15">Conditional Compilation</A>
			</UL>
			<LI><A HREF="#Heading16">Macro Functions</A>
			<UL>
				<LI><A HREF="#Heading17">Why All the Parentheses?</A>
			</UL>
			<LI><A HREF="#Heading18">Listing 17.3. Using parentheses in macros</A><A HREF="#Heading19">.</A>
			<UL>
				<LI><A HREF="#Heading20">Macros Versus Functions and Templates</A>
			</UL>
			<LI><A HREF="#Heading21">Inline Functions</A>
			<LI><A HREF="#Heading22">Listing 17.4. Using</A>
			<LI><A HREF="#Heading23">inline rather than a macro.</A>
			<LI><A HREF="#Heading24">String Manipulation</A>
			<UL>
				<LI><A HREF="#Heading25">Stringizing</A>
				<LI><A HREF="#Heading26">Concatenation</A>
			</UL>
			<LI><A HREF="#Heading27">Predefined Macros</A>
			<LI><A HREF="#Heading28">assert()</A>
			<LI><A HREF="#Heading29">Listing 17.5. A simple assert() macro</A><A HREF="#Heading30">.</A>
			<UL>
				<LI><A HREF="#Heading31">Debugging with assert()</A>
				<LI><A HREF="#Heading32">assert() Versus Exceptions</A>
				<LI><A HREF="#Heading33">Side Effects</A>
				<LI><A HREF="#Heading34">Class Invariants</A>
			</UL>
			<LI><A HREF="#Heading35">Listing 17.6. Using Invariants().</A>
			<UL>
				<LI><A HREF="#Heading36">Printing Interim Values</A>
			</UL>
			<LI><A HREF="#Heading37">Listing 17.7. Printing values in DEBUG mode</A><A HREF="#Heading38">.</A>
			<UL>
				<LI><A HREF="#Heading39">Debugging Levels</A>
			</UL>
			<LI><A HREF="#Heading40">Listing 17.8. Levels of debugging</A><A HREF="#Heading41">.</A>
			<LI><A HREF="#Heading42">Summary</A>
			<LI><A HREF="#Heading43">Q&amp;A</A>
			<LI><A HREF="#Heading44">Workshop</A>
			<UL>
				<LI><A HREF="#Heading45">Quiz</A>
				<LI><A HREF="#Heading46">Exercises</A>
			</UL>
		</UL>
	</UL>
</UL>

<P>
<HR SIZE="4">

<H2 ALIGN="CENTER"><A NAME="Heading1"></A><FONT COLOR="#000077">Day 17</FONT></H2>
<H2 ALIGN="CENTER"><A NAME="Heading2"></A><FONT COLOR="#000077">The Preprocessor</FONT></H2>
<P>Most of what you write in your source code files is C++. These are interpreted
by the compiler and turned into your program. Before the compiler runs, however,
the preprocessor runs, and this provides an opportunity for conditional compilation.
Today you will learn

<UL>
	<LI>What conditional compilation is and how to manage it.
	<P>
	<LI>How to write macros using the preprocessor.
	<P>
	<LI>How to use the preprocessor in finding bugs.
</UL>

<H3 ALIGN="CENTER"><A NAME="Heading3"></A><FONT COLOR="#000077">The Preprocessor
and the Compiler</FONT></H3>
<P>Every time you run your compiler, your preprocessor runs first. The preprocessor
looks for preprocessor instructions, each of which begins with a pound symbol (<TT>#</TT>).
The effect of each of these instructions is a change to the text of the source code.
The result is a new source code file, a temporary file that you normally don't see,
but that you can instruct the compiler to save so that you can examine it if you
want to.</P>
<P>The compiler does not read your original source code file; it reads the output
of the preprocessor and compiles that file. You've seen the effect of this already
with the <TT>#include</TT> directive. This instructs the preprocessor to find the
file whose name follows the <TT>#include</TT> directive, and to write it into the
intermediate file at that location. It is as if you had typed that entire file right
into your source code, and by the time the compiler sees the source code, the included
file is there.
<H3 ALIGN="CENTER"><A NAME="Heading4"></A><FONT COLOR="#000077">Seeing the Intermediate
Form</FONT></H3>
<P>Just about every compiler has a switch that you can set either in the integrated
development environment (IDE) or at the command line, and that instructs the compiler
to save the intermediate file. Check your compiler manual for the right switches
to set for your compiler, if you'd like to examine this file.
<H3 ALIGN="CENTER"><A NAME="Heading5"></A><FONT COLOR="#000077">Using #define</FONT></H3>
<P>The <TT>#define</TT> command defines a string substitution. If you write</P>
<PRE><FONT COLOR="#0066FF">#define BIG 512
</FONT></PRE>
<P>you have instructed the precompiler to substitute the string <TT>512</TT> wherever
it sees the string <TT>BIG</TT>. This is not a string in the C++ sense. The characters
<TT>512</TT> are substituted in your source code wherever the token <TT>BIG</TT>
is seen. A token is a string of characters that can be used wherever a string or
constant or other set of letters might be used. Thus, if you write</P>
<PRE><FONT COLOR="#0066FF">#define BIG 512
int myArray[BIG];
</FONT></PRE>
<P>The intermediate file produced by the precompiler will look like this:</P>
<PRE><FONT COLOR="#0066FF">int myArray[512];
</FONT></PRE>
<P>Note that the <TT>#define</TT> statement is gone. Precompiler statements are all
removed from the intermediate file; they do not appear in the final source code at
all.
<H4 ALIGN="CENTER"><A NAME="Heading6"></A><FONT COLOR="#000077">Using #define for
Constants</FONT></H4>
<P>One way to use <TT>#define</TT> is as a substitute for constants. This is almost
never a good idea, however, as <TT>#define</TT> merely makes a string substitution
and does no type checking. As explained in the section on constants, there are tremendous
advantages to using the <TT>const</TT> keyword rather than <TT>#define</TT>.
<H4 ALIGN="CENTER"><A NAME="Heading7"></A><FONT COLOR="#000077">Using #define for
Tests</FONT></H4>
<P>A second way to use <TT>#define,</TT> however, is simply to declare that a particular
character string is defined. Therefore, you could write</P>
<PRE><FONT COLOR="#0066FF">#define BIG
</FONT></PRE>
<P>Later, you can test whether <TT>BIG</TT> has been defined and take action accordingly.
The precompiler commands to test whether a string has been defined are <TT>#ifdef</TT>
and <TT>#ifndef</TT>. Both of these must be followed by the command <TT>#endif</TT>
before the block ends (before the next closing brace).</P>
<P><TT>#ifdef</TT> evaluates to <TT>TRUE</TT> if the string it tests has been defined
already. So, you can write</P>
<PRE><FONT COLOR="#0066FF">#ifdef DEBUG
cout &lt;&lt; &quot;Debug defined&quot;;
#endif
</FONT></PRE>
<P>When the precompiler reads the <TT>#ifdef</TT>, it checks a table it has built
to see if you've defined <TT>DEBUG</TT>. If you have, the <TT>#ifdef</TT> evaluates
to <TT>TRUE</TT>, and everything to the next <TT>#else</TT> or <TT>#endif</TT> is
written into the intermediate file for compiling. If it evaluates to <TT>FALSE</TT>,
nothing between <TT>#ifdef DEBUG</TT> and <TT>#endif</TT> will be written into the
intermediate file; it will be as if it were never in the source code in the first
place.</P>
<P>Note that <TT>#ifndef</TT> is the logical reverse of <TT>#ifdef</TT>. <TT>#ifndef</TT>
evaluates to <TT>TRUE</TT> if the string has not been defined up to that point in
the file.
<H4 ALIGN="CENTER"><A NAME="Heading8"></A><FONT COLOR="#000077">The #else Precompiler
Command</FONT></H4>
<P>As you might imagine, the term <TT>#else</TT> can be inserted between either <TT>#ifdef</TT>
or <TT>#ifndef</TT> and the closing <TT>#endif</TT>. Listing 17.1 illustrates how
these terms are used.</P>
<P><A NAME="Heading9"></A><FONT SIZE="4" COLOR="#000077"><B>Listing 17.1. Using #define.</B></FONT></P>
<PRE><FONT COLOR="#0066FF">1:     #define DemoVersion
2:     #define DOS_VERSION 5
3:     #include &lt;iostream.h&gt;
4:
5:
6:     int main()
7:     {
8:
9:     cout &lt;&lt; &quot;Checking on the definitions of DemoVersion, DOS_VERSION  &#194;                _and WINDOWS_VERSION...\n&quot;;
10:
11:    #ifdef DemoVersion
12:       cout &lt;&lt; &quot;DemoVersion defined.\n&quot;;
13:    #else
14:       cout &lt;&lt; &quot;DemoVersion not defined.\n&quot;;
15:    #endif
16:
17:    #ifndef DOS_VERSION
18:       cout &lt;&lt; &quot;DOS_VERSION not defined!\n&quot;;
19:    #else
20:       cout &lt;&lt; &quot;DOS_VERSION defined as: &quot; &lt;&lt; DOS_VERSION &lt;&lt; endl;
21:    #endif
22:
23:    #ifdef WINDOWS_VERSION
24:       cout &lt;&lt; &quot;WINDOWS_VERSION defined!\n&quot;;
25:    #else
26:       cout &lt;&lt; &quot;WINDOWS_VERSION was not defined.\n&quot;;
27:    #endif
28:
29:     cout &lt;&lt; &quot;Done.\n&quot;;
30:     return 0;
<TT>31: }</TT></FONT>
<FONT COLOR="#0066FF">
Output: Checking on the definitions of DemoVersion, DOS_VERSION 
&#194;                _and WINDOWS_VERSION...\n&quot;;
DemoVersion defined.
DOS_VERSION defined as: 5
WINDOWS_VERSION was not defined.
Done.
</FONT></PRE>
<P><FONT COLOR="#000077"><B>Analysis:</B></FONT><B> </B>On lines 1 and 2, <TT>DemoVersion</TT>
and <TT>DOS_VERSION</TT> are defined, with <TT>DOS_VERSION</TT> defined with the
string <TT>5</TT>. On line 11, the definition of <TT>DemoVersion</TT> is tested,
and because <TT>DemoVersion</TT> is defined (albeit with no value), the test is true
and the string on line 12 is printed.<BR>
On line 17 is the test that <TT>DOS_VERSION</TT> is not defined. Because <TT>DOS_VERSION</TT>
is defined, this test fails and execution jumps to line 20. Here the string <TT>5</TT>
is substituted for the word <TT>DOS_VERSION</TT>; this is seen by the compiler as</P>
<PRE><FONT COLOR="#0066FF">cout &lt;&lt; &quot;DOS_VERSION defined as: &quot; &lt;&lt; 5 &lt;&lt; endl;</FONT></PRE>
<P>Note that the first word <TT>DOS_VERSION</TT> is not substituted because it is
in a quoted string. The second <TT>DOS_VERSION</TT> is substituted, however, and
thus the compiler sees <TT>5</TT> as if you had typed <TT>5</TT> there.</P>
<P>Finally, on line 23, the program tests for <TT>WINDOWS_VERSION</TT>. Because you
did not define <TT>WINDOWS_VERSION</TT>, the test fails and the message on line 24
is printed.
<H3 ALIGN="CENTER"><A NAME="Heading10"></A><FONT COLOR="#000077">Inclusion and Inclusion
Guards</FONT></H3>
<P>You will create projects with many different files. You will probably organize
your directories so that each class has its own header file (HPP) with the class
declaration, and its own implementation file (CPP) with the source code for the class
methods.</P>
<P>Your <TT>main()</TT> function will be in its own CPP file, and all the CPP files
will be compiled into OBJ files, which will then be linked together into a single
program by the linker.</P>
<P>Because your programs will use methods from many classes, many header files will
be included in each file. Also, header files often need to include one another. For
example, the header file for a derived class's declaration must include the header
file for its base class.</P>
<P>Imagine that the <TT>Animal</TT> class is declared in the file <TT>ANIMAL.HPP</TT>.
The <TT>Dog</TT> class (which derives from <TT>Animal</TT>) must include the file
<TT>ANIMAL.HPP</TT> in <TT>DOG.HPP</TT>, or <TT>Dog</TT> will not be able to derive
from <TT>Animal</TT>. The <TT>Cat</TT> header also includes <TT>ANIMAL.HPP</TT> for
the same reason.</P>
<P>If you create a method that uses both a <TT>Cat</TT> and a <TT>Dog</TT>, you will
be in danger of including <TT>ANIMAL.HPP</TT> twice. This will generate a compile-time
error, because it is not legal to declare a class (<TT>Animal</TT>) twice, even though
the declarations are identical. You can solve this problem with inclusion guards.
At the top of your <TT>ANIMAL</TT> header file, you write these lines:</P>
<PRE><FONT COLOR="#0066FF">#ifndef ANIMAL_HPP
#define ANIMAL_HPP
...                     // the whole file goes here
#endif
</FONT></PRE>
<P>This says, if you haven't defined the term <TT>ANIMAL_HPP</TT>, go ahead and define
it now. Between the <TT>#define</TT> statement and the closing <TT>#endif</TT> are
the entire contents of the file.</P>
<P>The first time your program includes this file, it reads the first line and the
test evaluates to <TT>TRUE</TT>; that is, you have not yet defined <TT>ANIMAL_HPP</TT>.
So, it goes ahead and defines it and then includes the entire file.</P>
<P>The second time your program includes the <TT>ANIMAL.HPP</TT> file, it reads the
first line and the test evaluates to <TT>FALSE</TT>; <TT>ANIMAL.HPP</TT> has been
defined. It therefore skips to the next <TT>#else</TT> (there isn't one) or the next
<TT>#endif</TT> (at the end of the file). Thus, it skips the entire contents of the
file, and the class is not declared twice.</P>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美日韩综合| 男人的天堂久久精品| 天天色图综合网| 国产91精品免费| 欧美美女bb生活片| 国产精品久久久久久久久果冻传媒 | av中文字幕在线不卡| 欧美一区国产二区| 一区二区在线观看免费| 国产在线一区观看| 欧美在线色视频| 日韩理论在线观看| 大桥未久av一区二区三区中文| 在线播放亚洲一区| 亚洲影院理伦片| 99久久伊人精品| 欧美国产欧美综合| 久草精品在线观看| 日韩欧美一区电影| 五月婷婷色综合| 欧美日韩一区二区欧美激情| 亚洲婷婷国产精品电影人久久| 国产成人精品aa毛片| 欧美大白屁股肥臀xxxxxx| 亚洲va欧美va国产va天堂影院| 一本色道久久综合狠狠躁的推荐| 中文字幕成人网| 国产成人精品免费在线| 精品国产乱码久久久久久牛牛| 日韩成人dvd| 欧美另类高清zo欧美| 亚洲一区二区三区四区在线免费观看| 91丨九色porny丨蝌蚪| 国产精品免费av| 99在线视频精品| 亚洲欧美在线视频观看| 91首页免费视频| 亚洲精品五月天| 在线观看免费亚洲| 午夜激情综合网| 欧美一三区三区四区免费在线看| 日韩中文字幕一区二区三区| 91 com成人网| 韩国av一区二区三区| 国产亚洲欧美在线| 成人性生交大片| 亚洲天堂福利av| 在线视频国内一区二区| 视频一区二区三区在线| 日韩欧美亚洲国产另类| 国产美女一区二区| 国产精品超碰97尤物18| 91亚洲午夜精品久久久久久| 亚洲中国最大av网站| 9191精品国产综合久久久久久| 美腿丝袜亚洲三区| 久久久久久久一区| 91视频在线观看免费| 麻豆成人91精品二区三区| 国产日韩欧美在线一区| 91视频精品在这里| 日韩电影在线免费| 国产精品不卡在线| 欧美日本韩国一区二区三区视频| 蜜臀a∨国产成人精品| 欧美国产精品中文字幕| 日本福利一区二区| 久久不见久久见中文字幕免费| 国产区在线观看成人精品| 色综合天天综合网天天看片| 丝袜国产日韩另类美女| 亚洲国产激情av| 欧美日韩精品三区| 岛国一区二区三区| 石原莉奈在线亚洲二区| 国产精品久久久久久久久搜平片 | 日韩美女啊v在线免费观看| 精品视频资源站| 国产乱子轮精品视频| 一区二区三区高清在线| 91色视频在线| 国产一区二区女| 五月天国产精品| 中文字幕在线观看一区二区| 欧美一级生活片| 色一区在线观看| 国产老妇另类xxxxx| 天天影视色香欲综合网老头| 中文字幕精品—区二区四季| 正在播放亚洲一区| 91麻豆成人久久精品二区三区| 久久国产麻豆精品| 视频在线观看91| 亚洲乱码日产精品bd| 国产欧美精品一区| 欧美大度的电影原声| 欧美日韩精品系列| 日本乱码高清不卡字幕| 丁香婷婷综合色啪| 国产精品主播直播| 免费美女久久99| 三级亚洲高清视频| 亚洲一区在线观看视频| 亚洲图片欧美激情| 国产精品无圣光一区二区| 精品国产免费视频| 精品美女在线播放| 日韩你懂的在线观看| 6080yy午夜一二三区久久| 欧洲亚洲国产日韩| 欧美一级久久久久久久大片| 色综合久久久久| 91香蕉国产在线观看软件| 99九九99九九九视频精品| 成人免费看黄yyy456| 大胆亚洲人体视频| 国产不卡一区视频| 福利一区二区在线观看| 国产乱人伦精品一区二区在线观看 | 欧美日韩亚洲国产综合| 欧美在线免费观看亚洲| 欧美午夜精品久久久久久孕妇| 色乱码一区二区三区88 | 国产69精品一区二区亚洲孕妇| 精品一二三四区| 国产精品影视天天线| 大桥未久av一区二区三区中文| 国产乱人伦精品一区二区在线观看 | 久久久久国产成人精品亚洲午夜| 久久这里只有精品视频网| 精品久久久久久久久久久久久久久久久| 欧美一级艳片视频免费观看| 欧美精品一区二区三区四区 | 日韩一区二区三区免费观看| 日韩精品中午字幕| 国产日产欧美一区二区三区| 国产精品久久久久影视| 亚洲伊人伊色伊影伊综合网| 日韩高清在线观看| 国产精品18久久久久久久久 | 欧美日韩精品免费| 日韩欧美激情四射| 亚洲国产岛国毛片在线| 亚洲风情在线资源站| 久久精品国产色蜜蜜麻豆| youjizz国产精品| 欧美日韩精品系列| 国产欧美一区二区精品性| 亚洲蜜臀av乱码久久精品 | 日韩一级免费一区| 日本一区二区三区高清不卡| 一区二区高清在线| 国产美女一区二区三区| 91久久精品一区二区| 精品黑人一区二区三区久久| 国产精品福利一区| 日本在线播放一区二区三区| 成人动漫av在线| 欧美一区二区三区成人| 日本一区二区三区在线不卡| 2022国产精品视频| 亚洲欧洲精品一区二区精品久久久| 亚洲视频一二三| 经典三级在线一区| 99re6这里只有精品视频在线观看| 欧美亚洲图片小说| 国产精品久久777777| 亚洲成a人片在线观看中文| 久久成人免费网站| 波多野结衣视频一区| 精品剧情在线观看| 综合久久久久综合| 日本韩国欧美一区二区三区| 欧美xingq一区二区| 日韩毛片在线免费观看| 美女脱光内衣内裤视频久久影院| 国产精品亚洲视频| 欧美mv日韩mv国产| 亚洲青青青在线视频| 久久不见久久见中文字幕免费| 国产东北露脸精品视频| 91久久国产综合久久| 国产女同性恋一区二区| 青青草原综合久久大伊人精品优势| 国产suv精品一区二区883| www国产亚洲精品久久麻豆| 亚洲激情av在线| 国产成人a级片| 欧美午夜电影网| 亚洲精品国产一区二区三区四区在线 | 精品av久久707| 蜜桃在线一区二区三区| 在线观看网站黄不卡| 欧美激情中文字幕| 一区二区三区 在线观看视频 | 91精品国产综合久久久蜜臀图片| 亚洲乱码精品一二三四区日韩在线| 国产裸体歌舞团一区二区| 制服视频三区第一页精品| 日韩精品亚洲一区|