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

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

?? 021.htm

?? 21天內快速掌握c++語言
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
45:
46:           if (Jim.GetStatus()== PartTime)
47:              cout << "Jim is part time" << endl;
48:           else
49:              cout << "Jim is full time" << endl;
50:
51:           Jim.SetStatus(PartTime);
52:
53:           if (Jim.GetStatus())
54:              cout << "Jim is part time" << endl;
55:           else
56:              cout << "Jim is full time" << endl;
57:
58:           cout << "Jim is on the " ;
59:
60:           char Plan[80];
61:           switch (Jim.GetPlan())
62:           {
63:              case  OneMeal: strcpy(Plan,"One meal"); break;
64:              case  AllMeals: strcpy(Plan,"All meals"); break;
65:              case WeekEnds: strcpy(Plan,"Weekend meals"); break;
66:              case NoMeals: strcpy(Plan,"No Meals");break;
67:              default : cout << "Something bad went wrong!\n"; break;
68:           }
69:           cout << Plan << " food plan." << endl;
70:         return 0;
<TT>71: }</TT></FONT>
<FONT COLOR="#0066FF">
Output: Jim is part time
Jim is full time
Jim is on the No Meals food plan.
</FONT></PRE>
<P><FONT COLOR="#000077"><B>Analysis:</B></FONT><B> </B>On lines 3 to 7, several
enumerated types are defined. These serve to define the possible values for the bit
fields within the student class.<BR>
<TT><BR>
Student</TT> is declared in lines 8-27. While this is a trivial class, it is interesting
in that all the data is packed into five bits. The first bit represents the student's
status, full-time or part-time. The second bit represents whether or not this is
an undergraduate. The third bit represents whether or not the student lives in a
dorm. The final two bits represent the four possible food plans.</P>
<P>The class methods are written as for any other class, and are in no way affected
by the fact that these are bit fields and not integers or enumerated types.</P>
<P>The member function <TT>GetStatus()</TT> reads the Boolean bit and returns an
enumerated type, but this is not necessary. It could just as easily have been written
to return the value of the bit field directly. The compiler would have done the translation.</P>
<PRE>To prove that to yourself, replace the <TT>GetStatus()</TT> implementation with this code:</PRE>
<PRE><FONT COLOR="#0066FF" font style="font-size:10pt">STATUS student::GetStatus()
{
return myStatus;
}</FONT></PRE>
<P>There should be no change whatsoever to the functioning of the program. It is
a matter of clarity when reading the code; the compiler isn't particular.</P>
<P>Note that the code on line 46 must check the status and then print the meaningful
message. It is tempting to write this:</P>
<PRE><FONT COLOR="#0066FF" font style="font-size:10pt">cout &lt;&lt; &quot;Jim is &quot; &lt;&lt; Jim.GetStatus() &lt;&lt; endl;</FONT></PRE>
<P>That will simply print this:</P>
<PRE><FONT COLOR="#0066FF" font style="font-size:10pt">Jim is 0</FONT></PRE>
<P>The compiler has no way to translate the enumerated constant <TT>PartTime</TT>
into meaningful text.</P>
<P>On line 61, the program switches on the food plan, and for each possible value
it puts a reasonable message into the buffer, which is then printed on line 69. Note
again that the <TT>switch</TT> statement could have been written as follows:</P>
<PRE><FONT COLOR="#0066FF" font style="font-size:10pt">case  0: strcpy(Plan,&quot;One meal&quot;); break;
case  1: strcpy(Plan,&quot;All meals&quot;); break;
case  2: strcpy(Plan,&quot;Weekend meals&quot;); break;
case  3: strcpy(Plan,&quot;No Meals&quot;);break;</FONT></PRE>
<P>The most important thing about using bit fields is that the client of the class
need not worry about the data storage implementation. Because the bit fields are
private, you can feel free to change them later and the interface will not need to
change.
<CENTER>
<H3><A NAME="Heading30"></A><FONT COLOR="#000077">Style</FONT></H3>
</CENTER>
<P>As stated elsewhere in this book, it is important to adopt a consistent coding
style, though in many ways it doesn't matter which style you adopt. A consistent
style makes it easier to guess what you meant by a particular part of the code, and
you avoid having to look up whether you spelled the function with an initial cap
or not the last time you invoked it.</P>
<P>The following guidelines are arbitrary; they are based on the guidelines used
in projects I've worked on in the past, and they've worked well. You can just as
easily make up your own, but these will get you started.</P>
<P>As Emerson said, &quot;Foolish consistency is the hobgoblin of small minds,&quot;
but having some consistency in your code is a good thing. Make up your own, but then
treat it as if it were dispensed by the programming gods.
<CENTER>
<H4><A NAME="Heading31"></A><FONT COLOR="#000077">Indenting</FONT></H4>
</CENTER>
<P>Tab size should be four spaces. Make sure your editor converts each tab to four
spaces.
<CENTER>
<H4><A NAME="Heading32"></A><FONT COLOR="#000077">Braces</FONT></H4>
</CENTER>
<P>How to align braces can be the most controversial topic between C and C++ programmers.
Here are the tips I suggest:
<BR>
<UL>
	<LI>Matching braces should be aligned vertically.
	<P>
	<LI>The outermost set of braces in a definition or declaration should be at the left
	margin. Statements within should be indented. All other sets of braces should be
	in line with their leading statements.
	<P>
	<LI>No code should appear on the same line as a brace. For example:
</UL>
<BR>
<PRE><FONT COLOR="#0066FF" font style="font-size:10pt">if (condition==true)
{
j = k;
SomeFunction();
}
m++;
</FONT></PRE>
<CENTER>
<H4><A NAME="Heading33"></A><FONT COLOR="#000077">Long Lines</FONT></H4>
</CENTER>
<P>Keep lines to the width displayable on a single screen. Code that is off to the
right is easily overlooked, and scrolling horizontally is annoying. When a line is
broken, indent the following lines. Try to break the line at a reasonable place,
and try to leave the intervening operator at the end of the previous line (as opposed
to the beginning of the following line) so that it is clear that the line does not
stand alone and that there is more coming.</P>
<P>In C++, functions tend to be far shorter than they were in C, but the old, sound
advice still applies. Try to keep your functions short enough to print the entire
function on one page.
<CENTER>
<H4><A NAME="Heading34"></A><FONT COLOR="#000077">switch Statements</FONT></H4>
</CENTER>
<P>Indent switches as follows to conserve horizontal space:</P>
<PRE><FONT COLOR="#0066FF" font style="font-size:10pt">switch(variable)
{
case ValueOne:
ActionOne();
break;
case ValueTwo:
ActionTwo();
break;
default:
assert(&quot;bad Action&quot;);
break;
}
</FONT></PRE>
<CENTER>
<H4><A NAME="Heading35"></A><FONT COLOR="#000077">Program Text</FONT></H4>
</CENTER>
<P>There are several tips you can use to create code that is easy to read. Code that
is easy to read is easy to maintain.
<BR>
<UL>
	<LI>Use whitespace to help readability.
	<P>
	<LI>Objects and arrays are really referring to one thing. Don't use spaces within
	object references (<TT>.</TT>, <TT>-&gt;</TT>, <TT>[]</TT>).
	<P>
	<LI>Unary operators are associated with their operands, so don't put a space between
	them. Do put a space on the side away from the operand. Unary operators include <TT>!</TT>,
	<TT>~</TT>, <TT>++</TT>, <TT>--</TT>, <TT>-</TT>, <TT>*</TT> (for pointers), <TT>&amp;</TT>
	(casts), <TT>sizeof</TT>.
	<P>
	<LI>Binary operators should have spaces on both sides: <TT>+</TT>, <TT>=</TT>, <TT>*</TT>,
	<TT>/</TT>, <TT>%</TT>, <TT>&gt;&gt;</TT>, <TT>&lt;&lt;</TT>, <TT>&lt;</TT>, <TT>&gt;</TT>,
	<TT>==</TT>, <TT>!=</TT>, <TT>&amp;</TT>, <TT>|</TT>, <TT>&amp;&amp;</TT>, <TT>||</TT>,
	<TT>?:</TT>, <TT>=</TT>, <TT>+=</TT>, and so on.
	<P>
	<LI>Don't use lack of spaces to indicate precedence (<TT>4+ 3*2</TT>).
	<P>
	<LI>Put a space after commas and semicolons, not before.
	<P>
	<LI>Parentheses should not have spaces on either side.
	<P>
	<LI>Keywords, such as <TT>if</TT>, should be set off by a space: <TT>if (a == b)</TT>.
	<P>
	<LI>The body of a comment should be set off from the <TT>//</TT> with a space.
	<P>
	<LI>Place the pointer or reference indicator next to the type name, not the variable
	name:
</UL>
<BR>
<PRE><FONT COLOR="#0066FF" font style="font-size:10pt">char* foo;
int&amp; theInt;
</FONT></PRE>
<BR>
<UL>
	<LI>rather than
</UL>
<BR>
<PRE><FONT COLOR="#0066FF" font style="font-size:10pt">char *foo;
int &amp;theInt;
</FONT></PRE>
<BR>
<UL>
	<LI>Do not declare more than one variable on the same line.
</UL>
<BR>
<CENTER>
<H4><A NAME="Heading36"></A><FONT COLOR="#000077">Identifier Names</FONT></H4>
</CENTER>
<P>Here are some guidelines for working with identifiers.
<BR>
<UL>
	<LI>Identifier names should be long enough to be descriptive.
	<P>
	<LI>Avoid cryptic abbreviations.
	<P>
	<LI>Take the time and energy to spell things out.
	<P>
	<LI>Do not use Hungarian notation. C++ is strongly typed and there is no reason to
	put the type into the variable name. With user-defined types (classes), Hungarian
	notation quickly breaks down. The exceptions to this may be to use a prefix for pointers
	(<TT>p</TT>) and references (<TT>r</TT>), as well as for class member variables (<TT>its</TT>).
	<P>
	<LI>Short names (<TT>i</TT>, <TT>p</TT>, <TT>x</TT>, and so on) should only be used
	where their brevity makes the code more readable and where the usage is so obvious
	that a descriptive name is not needed.
	<P>
	<LI>The length of a variable's name should be proportional to its scope.
	<P>
	<LI>Make sure identifiers look and sound different from one another to minimize confusion.
	<P>
	<LI>Function (or method) names are usually verbs or verb-noun phrases: <TT>Search()</TT>,
	<TT>Reset()</TT>, <TT>FindParagraph()</TT>, <TT>ShowCursor()</TT>. Variable names
	are usually abstract nouns, possibly with an additional noun: <TT>count</TT>, <TT>state</TT>,
	<TT>windSpeed</TT>, <TT>windowHeight</TT>. Boolean variables should be named appropriately:
	<TT>windowIconized</TT>, <TT>fileIsOpen</TT>.
</UL>
<BR>
<CENTER>
<H4><A NAME="Heading37"></A><FONT COLOR="#000077">Spelling and Capitalization of
Names</FONT></H4>
</CENTER>
<P>Spelling and capitalization should not be overlooked when creating your own style.
Some tips for these areas include the following:
<BR>
<UL>
	<LI>Use all uppercase and underscore to separate the logical words of names, such
	as <TT>SOURCE_FILE_TEMPLATE</TT>. Note, however, that these are rare in C++. Consider
	using constants and templates in most cases.
	<P>
	<LI>All other identifiers should use mixed case--no underscores. Function names,
	methods, class, <TT>typedef</TT>, and <TT>struct</TT> names should begin with a capitalized
	letter. Elements such as data members or locals should begin with a lowercase letter.
	<P>
	<LI>Enumerated constants should begin with a few lowercase letters as an abbreviation
	for the <TT>enum</TT>. For example:
</UL>
<BR>
<PRE><FONT COLOR="#0066FF" font style="font-size:10pt">enum TextStyle
{
tsPlain,
tsBold,
tsItalic,
tsUnderscore,
};
</FONT></PRE>
<CENTER>
<H4><A NAME="Heading38"></A><FONT COLOR="#000077">Comments</FONT></H4>
</CENTER>
<P>Comments can make it much easier to understand a program. Sometimes you will not
work on a program for several days or even months. In this time you can forget what
certain code does or why it has been included. Problems in understanding code can
also occur when someone else reads your code. Comments that are applied in a consistent,
well thought out style can be well worth the effort. There are several tips to remember
concerning comments:
<BR>
<UL>
	<LI>Wherever possible, use C++ <TT>//</TT> comments rather than the <TT>/* */</TT>
	style.
	<P>
	<LI>Higher-level comments are infinitely more important than process details. Add
	value; do not merely restate the code.
</UL>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲特级片在线| 国产成人午夜精品5599| 亚洲国产一区二区三区| 中文字幕在线观看不卡| 国产精品久久久久婷婷| 欧美经典三级视频一区二区三区| 精品久久一二三区| 久久先锋影音av鲁色资源网| 久久久久亚洲蜜桃| 久久噜噜亚洲综合| 国产精品理伦片| 亚洲欧美日韩国产中文在线| 一区二区三区欧美亚洲| 成人免费小视频| 亚洲欧美偷拍卡通变态| 一区二区三区精品久久久| 一区二区三区丝袜| 天天亚洲美女在线视频| 琪琪久久久久日韩精品| 久久99国产精品久久99果冻传媒| 九九**精品视频免费播放| 国产在线国偷精品免费看| 国产成人综合在线| 91麻豆精品视频| 欧美日韩你懂得| 日韩欧美在线网站| 国产午夜久久久久| 伊人婷婷欧美激情| 日韩黄色片在线观看| 韩国女主播一区| 99久久精品国产观看| 欧美日韩综合不卡| 26uuu另类欧美| 亚洲男人天堂av网| 视频一区二区三区在线| 国产原创一区二区| 在线精品视频一区二区三四| 欧美r级在线观看| 亚洲欧洲色图综合| 琪琪一区二区三区| 91网站视频在线观看| 日韩一区二区三| 国产精品护士白丝一区av| 视频一区欧美日韩| 99久久99久久久精品齐齐| 欧美日韩国产片| 久久久久97国产精华液好用吗| 亚洲欧美电影一区二区| 美女爽到高潮91| 色婷婷国产精品| 精品国产人成亚洲区| 亚洲精品成人少妇| 国产激情偷乱视频一区二区三区 | 精品视频1区2区3区| 精品久久免费看| 亚洲精品精品亚洲| 国产裸体歌舞团一区二区| 欧美性做爰猛烈叫床潮| 国产精品婷婷午夜在线观看| 天天综合天天综合色| voyeur盗摄精品| 精品国产免费人成在线观看| 亚洲国产综合人成综合网站| 国产成a人无v码亚洲福利| 69p69国产精品| 成人欧美一区二区三区小说 | 激情图片小说一区| 色狠狠av一区二区三区| 日本一区二区三区国色天香 | 欧美日韩一卡二卡三卡| 国产亚洲精品精华液| 日本成人在线不卡视频| 在线观看91精品国产入口| 国产精品天干天干在观线| 美国十次了思思久久精品导航| 色婷婷久久久久swag精品| 欧美国产综合一区二区| 看片网站欧美日韩| 欧美一区二区三区日韩| 亚洲国产va精品久久久不卡综合| fc2成人免费人成在线观看播放 | 国产精品国产馆在线真实露脸| 蜜乳av一区二区三区| 欧美日韩情趣电影| 一区二区三区日韩欧美精品| 成人sese在线| 中文在线免费一区三区高中清不卡 | 一区二区三区蜜桃网| av高清久久久| 中文字幕色av一区二区三区| 国产高清亚洲一区| 久久久蜜臀国产一区二区| 国产一区美女在线| 欧美精品一区二区三区蜜臀| 久久 天天综合| 日韩欧美一区二区在线视频| 奇米亚洲午夜久久精品| 91精品国产福利在线观看| 天天综合天天综合色| 欧美综合视频在线观看| 亚洲综合色噜噜狠狠| 在线精品国精品国产尤物884a| 亚洲欧美国产毛片在线| 日本韩国欧美一区二区三区| 亚洲欧洲综合另类| 在线观看一区二区视频| 一区二区三区在线影院| 欧美艳星brazzers| 亚洲小说春色综合另类电影| 欧美日韩国产欧美日美国产精品| 亚洲成av人综合在线观看| 欧美男女性生活在线直播观看| 亚洲成a天堂v人片| 日韩视频免费观看高清完整版在线观看| 日韩电影在线观看电影| 欧美sm美女调教| 成人永久免费视频| 亚洲色图欧洲色图婷婷| 在线观看视频一区二区| 日韩和欧美一区二区三区| 欧美成人a∨高清免费观看| 国产精品亚洲一区二区三区在线 | 欧美aaaaa成人免费观看视频| 91精品国产综合久久精品app| 美女视频网站黄色亚洲| 久久亚洲影视婷婷| 成人avav影音| 亚洲成人在线网站| 欧美大片拔萝卜| 成人精品视频网站| 亚洲一区二区在线视频| 日韩欧美区一区二| 成人免费高清视频在线观看| 亚洲一区二区视频在线| 日韩欧美一级二级三级久久久| 国产mv日韩mv欧美| 亚洲图片欧美视频| 亚洲精品一区二区三区影院| bt欧美亚洲午夜电影天堂| 丝袜脚交一区二区| 欧美国产一区二区| 欧美色男人天堂| 国产美女在线观看一区| 亚洲另类在线一区| 日韩欧美色综合网站| aaa欧美日韩| 香蕉成人伊视频在线观看| 久久久久久久久久久久久女国产乱| 91在线视频网址| 麻豆精品视频在线观看免费| 国产精品高潮呻吟| 日韩一区二区在线看片| 99国产麻豆精品| 精品一区二区三区免费毛片爱| 亚洲日本在线看| 日韩欧美黄色影院| 91原创在线视频| 久久99精品久久只有精品| 亚洲自拍偷拍综合| 国产婷婷色一区二区三区四区| 91九色02白丝porn| 国产一区二区三区黄视频| 亚洲一区二区三区免费视频| 国产午夜精品福利| 91精品国产综合久久福利| 99久久久免费精品国产一区二区| 久久99国内精品| 午夜av一区二区三区| 国产精品成人一区二区三区夜夜夜| 日韩美女一区二区三区| 欧美日韩中文另类| 成人做爰69片免费看网站| 日本不卡的三区四区五区| 亚洲一区二区视频| 日韩理论片一区二区| 久久久久久久综合色一本| 91精品国产麻豆| 欧美亚一区二区| 一本大道久久精品懂色aⅴ| 国产成人在线视频网站| 久久精品久久99精品久久| 日韩一区精品视频| 一二三区精品视频| 1024成人网| 中文字幕一区二区在线播放 | 日韩精品乱码av一区二区| 一区二区三区高清不卡| 中文字幕色av一区二区三区| 久久久久久久精| 精品国产乱码91久久久久久网站| 欧美久久久久久久久久| 91国产福利在线| 一本大道av伊人久久综合| 国产高清精品久久久久| 激情六月婷婷综合| 韩国三级电影一区二区| 极品少妇xxxx精品少妇偷拍| 美腿丝袜亚洲三区| 免费在线观看视频一区| 午夜av电影一区|