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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? 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>

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美剧情片在线观看| 国产精品1024| 欧美色中文字幕| 一区二区高清视频在线观看| 一本久道中文字幕精品亚洲嫩| 亚洲视频在线一区观看| 在线欧美一区二区| 日韩精品欧美精品| 欧美成人精品二区三区99精品| 国内精品伊人久久久久av影院| 久久久久国产精品厨房| 成人黄色在线看| 有坂深雪av一区二区精品| 欧美年轻男男videosbes| 久久精品国产久精国产| 国产嫩草影院久久久久| 一本久久精品一区二区| 日本免费新一区视频| 久久久www成人免费无遮挡大片| 成人国产精品免费观看视频| 一级中文字幕一区二区| 日韩一区二区三区高清免费看看 | 日韩视频中午一区| 国产精品羞羞答答xxdd| 亚洲青青青在线视频| 欧美一区二区福利视频| 国产成人8x视频一区二区 | 2020国产成人综合网| 国产91精品精华液一区二区三区| 亚洲色图制服丝袜| 日韩一区二区三区四区五区六区| 国产福利精品导航| 午夜电影久久久| 日本一区二区三区视频视频| 欧美日韩一区二区不卡| 国产精品69毛片高清亚洲| 亚洲午夜一二三区视频| 国产三级欧美三级| 欧美酷刑日本凌虐凌虐| 成人av综合一区| 日本人妖一区二区| 亚洲精品高清在线| 国产日产精品1区| 3d动漫精品啪啪| 99久久精品国产观看| 免费人成精品欧美精品| 伊人夜夜躁av伊人久久| 久久嫩草精品久久久久| 欧美日韩亚洲综合一区| 99久久综合精品| 国产一区不卡视频| 日本成人中文字幕在线视频| 亚洲另类色综合网站| 久久久99免费| 日韩欧美国产wwwww| 精品视频999| 在线观看不卡视频| 91啪亚洲精品| 波多野洁衣一区| 国产成人在线视频免费播放| 免费日韩伦理电影| 青青草国产精品亚洲专区无| 亚洲最大的成人av| 亚洲蜜臀av乱码久久精品| 中文字幕成人在线观看| 久久久久国产精品人| 日韩精品在线一区二区| 日韩一区二区视频| 3d成人h动漫网站入口| 欧美男同性恋视频网站| 欧美性大战xxxxx久久久| 色欧美片视频在线观看在线视频| 成人午夜激情视频| 成人精品视频一区二区三区| 国产在线乱码一区二区三区| 久久精品国产精品亚洲综合| 蜜臀a∨国产成人精品| 美国三级日本三级久久99| 日韩电影在线一区| 久久精品国产网站| 国产麻豆视频一区| 国产福利91精品| 成人avav影音| 99精品在线免费| 欧洲精品中文字幕| 欧美吞精做爰啪啪高潮| 欧美三级电影在线看| 欧美精品久久一区二区三区| 制服丝袜一区二区三区| 精品国内二区三区| 国产欧美一区二区精品秋霞影院 | 欧美国产日韩一二三区| 国产精品欧美久久久久无广告 | 99视频一区二区| 99国产精品99久久久久久| 色综合视频一区二区三区高清| 99久久综合狠狠综合久久| 日韩一区二区三| 日韩免费性生活视频播放| 久久精品综合网| 亚洲欧美国产77777| 亚洲最大成人网4388xx| 日本亚洲欧美天堂免费| 国产一二三精品| 99国产精品久久久久久久久久久| av高清不卡在线| 欧美色倩网站大全免费| 欧美成人高清电影在线| 国产精品丝袜一区| 亚洲成人一区二区| 狠狠色狠狠色合久久伊人| av午夜精品一区二区三区| 欧美性猛交一区二区三区精品| 91精品视频网| 国产精品久久久久久久久免费丝袜| 1024成人网色www| 免费欧美日韩国产三级电影| 成人久久视频在线观看| 欧美天堂亚洲电影院在线播放| 日韩欧美国产三级电影视频| 国产精品电影一区二区| 欧美96一区二区免费视频| 成人性生交大片免费| 欧美精品tushy高清| 国产精品免费丝袜| 免费在线观看日韩欧美| 99久久久免费精品国产一区二区| 欧美色中文字幕| 国产精品毛片a∨一区二区三区 | 国产三级三级三级精品8ⅰ区| 亚洲激情五月婷婷| 久久成人免费电影| 欧美日韩中文字幕一区二区| 中文在线资源观看网站视频免费不卡| 亚洲综合丁香婷婷六月香| 国产成人精品亚洲777人妖| 欧美伦理电影网| 国产精品欧美久久久久一区二区| 美女网站色91| 精品视频全国免费看| 亚洲丝袜美腿综合| 国产suv精品一区二区6| 日韩午夜激情av| 亚洲高清不卡在线观看| 99久久婷婷国产| 国产欧美日韩在线| 久久99精品一区二区三区三区| 欧美中文字幕一二三区视频| 国产精品美女久久久久久久久| 成人综合在线观看| 精品三级在线看| 日韩不卡一区二区三区 | 成人午夜短视频| 久久久综合视频| 久久se这里有精品| 日韩欧美在线一区二区三区| 亚洲成av人片| 精品视频资源站| 亚洲国产一区二区三区青草影视| 91亚洲精品久久久蜜桃| 中文字幕一区三区| 成人黄色777网| 国产精品福利在线播放| 国产高清不卡二三区| 日本一区二区三区高清不卡| 国产美女在线观看一区| 久久综合精品国产一区二区三区| 久久精品久久久精品美女| 91精品午夜视频| 美女看a上一区| 日韩精品在线一区二区| 韩国欧美一区二区| 亚洲精品一区二区三区蜜桃下载| 男男成人高潮片免费网站| 91精品国产福利在线观看| 美日韩一级片在线观看| 精品人伦一区二区色婷婷| 精品一区二区三区香蕉蜜桃| 精品少妇一区二区三区免费观看| 精品一区二区免费在线观看| 久久这里只有精品6| 国产成人久久精品77777最新版本| 国产欧美日产一区| 91玉足脚交白嫩脚丫在线播放| 一区二区三区在线观看动漫| 在线观看免费视频综合| 日韩高清不卡一区| 欧美精品一区男女天堂| 成人av网站在线观看| 亚洲精品成人精品456| 欧美美女网站色| 国产一区不卡在线| 中文字幕一区在线观看视频| 欧美性受xxxx黑人xyx性爽| 日韩激情av在线| 久久久噜噜噜久久中文字幕色伊伊| 国产精品白丝av| 一区二区三区中文在线观看| 777a∨成人精品桃花网| 国产经典欧美精品|