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

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

?? apd.htm

?? good book for learning c++ standard language
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
	to the function?</B><BR>
	<BR>
	No. All parameters are identified by position, not name.<BR>
	<BR>
	<B>3. If a function doesn't return a value, how do you declare the function?</B><BR>
	<BR>
	Declare the function to return <TT>void</TT>.<BR>
	<BR>
	<B>4. If you don't declare a return value, what type of return value is assumed?</B><BR>
	<BR>
	Any function that does not explicitly declare a return type returns <TT>int</TT>.<BR>
	<BR>
	<B>5. What is a local variable?</B><BR>
	<BR>
	A local variable is a variable passed into or declared within a block, typically
	a function. It is visible only within the block.<BR>
	<BR>
	<B>6. What is scope?</B><BR>
	<BR>
	Scope refers to the visibility and lifetime of local and global variables. Scope
	is usually established by a set of braces.<BR>
	<BR>
	<B>7. What is recursion?</B><BR>
	<BR>
	Recursion generally refers to the ability of a function to call itself.<BR>
	<BR>
	<B>8. When should you use global variables?</B><BR>
	<BR>
	Global variables are typically used when many functions need access to the same data.
	Global variables are very rare in C++; once you know how to create static class variables,
	you will almost never create global variables.<BR>
	<BR>
	<B>9. What is function overloading?</B><BR>
	<BR>
	Function overloading is the ability to write more than one function with the same
	name, distinguished by the number or type of the parameters.<BR>
	<BR>
	<B>10. What is polymorphism?</B><BR>
	<BR>
	Polymorphism is the ability to treat many objects of differing but related types
	without regard to their differences. In C++, polymorphism is accomplished by using
	class derivation and virtual functions.
</DL>

<H4 ALIGN="CENTER"><A NAME="Heading17"></A><FONT COLOR="#000077">Exercises</FONT></H4>

<DL>
	<DD><B>1.</B> Write the prototype for a function named <TT>Perimeter</TT>, which
	returns an <TT>unsigned long int</TT> and which takes two parameters, both <TT>unsigned
	short</TT> <TT>int</TT>s.<BR>
	u<TT>nsigned long int</TT> <TT>Perimeter</TT>(<TT>unsigned short int</TT>, <TT>unsigned
	short int</TT>);<BR>
	<BR>
	<B>2.</B> Write the definition of the function <TT>Perimeter</TT> as described in
	Exercise 1. The two parameters represent the length and width of a rectangle and
	have the function return the perimeter (twice the length plus twice the width).
</DL>

<PRE><FONT COLOR="#0066FF"><TT>unsigned long int Perimeter</TT>(<TT>unsigned short int length</TT>, <TT>unsigned short int width</TT>)</FONT>
<FONT COLOR="#0066FF">
{
  return 2*length + 2*width;
}
</FONT></PRE>

<DL>
	<DD><B>3</B>. BUG BUSTERS: What is wrong with the function?
</DL>

<PRE><FONT COLOR="#0066FF">#include &lt;iostream.h&gt;
void myFunc(unsigned short int x);
int main()
{
    unsigned short int x, y;
    y = myFunc(int);
    cout &lt;&lt; &quot;x: &quot; &lt;&lt; x &lt;&lt; &quot; y: &quot; &lt;&lt; y &lt;&lt; &quot;\n&quot;;
return 0;
}

void myFunc(unsigned short int x)
{
    return (4*x);
}</FONT></PRE>

<DL>
	<DD>The function is declared to return <TT>void</TT> and it cannot return a value.<BR>
	<BR>
	<B>4.</B> BUG BUSTERS: What is wrong with the function?
</DL>

<PRE><FONT COLOR="#0066FF">#include &lt;iostream.h&gt;
int myFunc(unsigned short int x);
int main()
{
    unsigned short int x, y;
    y = myFunc(int);
    cout &lt;&lt; &quot;x: &quot; &lt;&lt; x &lt;&lt; &quot; y: &quot; &lt;&lt; y &lt;&lt; &quot;\n&quot;;
return 0;
}

int myFunc(unsigned short int x)
{
    return (4*x);
}
</FONT></PRE>

<DL>
	<DD>This function would be fine, but there is a semicolon at the end of the function
	definition's header.<BR>
	<BR>
	<B>5.</B> Write a function that takes two <TT>unsigned short</TT> <TT>int</TT> arguments
	and returns the result of dividing the first by the second. Do not do the division
	if the second number is <TT>0</TT>, but do return <TT>-1</TT>.<BR>
	<TT>short int Divider</TT>(<TT>unsigned short int valOne</TT>, <TT>unsigned short
	int valTwo</TT>)
</DL>

<PRE><FONT COLOR="#0066FF">{
    if (valTwo == 0)
          return -1;
    else
          return valOne / valTwo;
}
</FONT></PRE>

<DL>
	<DD><B>6.</B> Write a program that asks the user for two numbers and calls the function
	you wrote in Exercise 5. Print the answer, or print an error message if you get <TT>-1</TT>.
</DL>

<PRE><FONT COLOR="#0066FF">#include &lt;iostream.h&gt;
typedef unsigned short int USHORT;
typedef unsigned long int ULONG;
short int Divider(
unsigned short int valone,
unsigned short int valtwo);
int main()
{
    USHORT one, two;
    short int answer;
    cout &lt;&lt; &quot;Enter two numbers.\n Number one: &quot;;
    cin &gt;&gt; one;
    cout &lt;&lt; &quot;Number two: &quot;;
    cin &gt;&gt; two;
    answer = Divider(one, two);
    if (answer &gt; -1)
       cout &lt;&lt; &quot;Answer: &quot; &lt;&lt; answer;
    else
       cout &lt;&lt; &quot;Error, can't divide by zero!&quot;;
return 0;
}
</FONT></PRE>

<DL>
	<DD><B>7. </B>Write a program that asks for a number and a power. Write a recursive
	function that takes the number to the power. Thus, if the number is 2 and the power
	is 4, the function will return <TT>16</TT>.
</DL>

<PRE><FONT COLOR="#0066FF">#include &lt;iostream.h&gt;
typedef unsigned short USHORT;
typedef unsigned long ULONG;
ULONG GetPower(USHORT n, USHORT power);
int main()
{
   USHORT number, power;
   ULONG answer;
   cout &lt;&lt; &quot;Enter a number: &quot;;
   cin &gt;&gt; number;
   cout &lt;&lt; &quot;To what power? &quot;;
   cin &gt;&gt; power;
   answer = GetPower(number,power);
   cout &lt;&lt; number &lt;&lt; &quot; to the &quot; &lt;&lt; power &lt;&lt; &quot;th power is &quot; &lt;&lt;
answer &lt;&lt; endl;
return 0;
}

ULONG GetPower(USHORT n, USHORT power)
{
    if(power == 1)
     return n;
    else
       return (n * GetPower(n,power-1));
}
</FONT></PRE>
<H3 ALIGN="CENTER"><FONT COLOR="#0066FF"></FONT></H3>
<H3><A NAME="Heading18"></A><FONT COLOR="#000077">Day 6</FONT></H3>
<H4 ALIGN="CENTER"><A NAME="Heading19"></A><FONT COLOR="#000077">Quiz</FONT></H4>

<DL>
	<DD><B>1. What is the dot operator, and what is it used for?</B><BR>
	<BR>
	The dot operator is the period (<TT>.</TT>). It is used to access the members of
	the class.<BR>
	<BR>
	<B>2. Which sets aside memory--declaration or definition?</B><BR>
	<BR>
	Definitions of variables set aside memory. Declarations of classes don't set aside
	memory.<BR>
	<BR>
	<B>3. Is the declaration of a class its interface or its implementation?</B><BR>
	<BR>
	The declaration of a class is its interface; it tells clients of the class how to
	interact with the class. The implementation of the class is the set of member functions
	stored--usually in a related CPP file.<BR>
	<BR>
	<B>4. What is the difference between public and private data members?</B><BR>
	<BR>
	Public data members can be accessed by clients of the class. Private data members
	can be accessed only by member functions of the class.<BR>
	<BR>
	<B>5. Can member functions be private?<BR>
	</B><BR>
	Yes. Both member functions and member data can be private.<BR>
	<BR>
	<B>6. Can member data be public?</B><BR>
	<BR>
	Although member data can be public, it is good programming practice to make it private
	and to provide public accessor functions to the data.<BR>
	<BR>
	<B>7. If you declare two <TT>Cat</TT> objects, can they have different values in
	their <TT>itsAge</TT> member data?</B><BR>
	<BR>
	Yes. Each object of a class has its own data members.<BR>
	<BR>
	<B>8. Do class declarations end with a semicolon? Do class method definitions?</B><BR>
	<BR>
	Declarations end with a semicolon after the closing brace; function definitions do
	not.<BR>
	<BR>
	<B>9. What would the header for a <TT>Cat</TT> function, <TT>Meow</TT>, that takes
	no parameters and returns <TT>void</TT> look like?<BR>
	</B><BR>
	The header for a <TT>Cat</TT> function, <TT>Meow()</TT>, that takes no parameters
	and returns <TT>void</TT> looks like this:
</DL>

<PRE><FONT COLOR="#0066FF">void Cat::Meow()
</FONT></PRE>

<DL>
	<DD><B>10. What function is called to initialize a class?<BR>
	</B><BR>
	The constructor is called to initialize a class.
</DL>

<H4 ALIGN="CENTER"><A NAME="Heading20"></A><FONT COLOR="#000077">Exercises</FONT></H4>

<DL>
	<DD><B>1. </B>Write the code that declares a class called <TT>Employee</TT> with
	these data members: <TT>age</TT>, <TT>yearsOfService</TT>, and <TT>Salary</TT>.
</DL>

<PRE><FONT COLOR="#0066FF">class Employee
{
    int Age;
    int YearsOfService;
    int Salary;
};
</FONT></PRE>

<DL>
	<DD><B>2.</B> Rewrite the <TT>Employee</TT> class to make the data members private,
	and provide public accessor methods to get and set each of the data members.
</DL>

<PRE><FONT COLOR="#0066FF">class Employee
{
public:
    int GetAge() const;
    void SetAge(int age);
    int GetYearsOfService()const;
    void SetYearsOfService(int years);
    int GetSalary()const;
    void SetSalary(int salary);

private:
    int Age;
    int YearsOfService;
    int Salary;
};
</FONT></PRE>

<DL>
	<DD><B>3.</B> Write a program with the <TT>Employee</TT> class that makes two <TT>Employee</TT>s;
	sets their <TT>age</TT>, <TT>YearsOfService</TT>, and <TT>Salary</TT>; and prints
	their values.
</DL>

<PRE><FONT COLOR="#0066FF">main()
{
    Employee John;
    Employee Sally;
    John.SetAge(30);
    John.SetYearsOfService(5);
    John.SetSalary(50000);

    Sally.SetAge(32);
    Sally.SetYearsOfService(8);
    Sally.SetSalary(40000);

    cout &lt;&lt; &quot;At AcmeSexist company, John and Sally have the same
job.\n&quot;;
    cout &lt;&lt; &quot;John is &quot; &lt;&lt; John.GetAge() &lt;&lt; &quot; years old and he has
been with&quot;;
    cout &lt;&lt; &quot;the firm for &quot; &lt;&lt; John.GetYearsOfService &lt;&lt; &quot;
years.\n&quot;;
    cout &lt;&lt; &quot;John earns $&quot; &lt;&lt; John.GetSalary &lt;&lt; &quot; dollars per
year.\n\n&quot;;
    cout &lt;&lt; &quot;Sally, on the other hand is &quot; &lt;&lt; Sally.GetAge() &lt;&lt; &quot;
years old and has&quot;;
    cout &lt;&lt; &quot;been with the company &quot; &lt;&lt; Sally.GetYearsOfService;
    cout &lt;&lt; &quot; years. Yet Sally only makes $&quot; &lt;&lt; Sally.GetSalary();
    cout &lt;&lt; &quot; dollars per year!  Something here is unfair.&quot;;
</FONT></PRE>

<DL>
	<DD><B>4.</B> Continuing from Exercise 3, provide a method of <TT>Employee</TT> that
	reports how many thousands of dollars the employee earns, rounded to the nearest
	1,000.
</DL>

<PRE><FONT COLOR="#0066FF">float Employee:GetRoundedThousands()const
{
    return Salary / 1000;
}
</FONT></PRE>

<DL>
	<DD><B>5. </B>Change the <TT>Employee</TT> class so that you can initialize <TT>age</TT>,
	<TT>YearsOfService</TT>, and <TT>Salary</TT> when you create the employee.
</DL>

<PRE><FONT COLOR="#0066FF">class Employee
{
public:

    Employee(int age, int yearsOfService, int salary);
    int GetAge()const;
    void SetAge(int age);
    int GetYearsOfService()const;
    void SetYearsOfService(int years);
    int GetSalary()const;
    void SetSalary(int salary);

private:
    int Age;
    int YearsOfService;
    int Salary;
};
</FONT></PRE>

<DL>
	<DD><B>6.</B> BUG BUSTERS: What is wrong with the following declaration?
</DL>

<PRE><FONT COLOR="#0066FF">class Square
{
public:
    int Side;
}</FONT></PRE>

<DL>
	<DD>Class declarations must end with a semicolon.<BR>
	<BR>
	<B>7</B>. BUG BUSTERS: Why isn't the following class declaration very useful?
</DL>

<PRE><FONT COLOR="#0066FF">class Cat
{
    int GetAge()const;
private:
    int itsAge;
};</FONT></PRE>

<DL>
	<DD>The accessor <TT>GetAge()</TT> is private. Remember: All class members are private
	unless you say otherwise.<BR>
	<BR>
	<B>8</B>. BUG BUSTERS: What three bugs in this code will the compiler find?
</DL>

<PRE><FONT COLOR="#0066FF">class  TV
{
public:
    void SetStation(int Station);
    int GetStation() const;
private:
    int itsStation;
};

main()
{
    TV myTV;
    myTV.itsStation = 9;
    TV.SetStation(10);
    TV myOtherTv(2);
}
</FONT></PRE>

<DL>
	<DD>You can't access <TT>itsStation</TT> directly. It is private.<BR>
	You can't call <TT>SetStation()</TT> on the class. You can call <TT>SetStation()</TT>
	only on objects.<BR>
	You can't initialize <TT>itsStation</TT> because there is no matching constructor.
</DL>

<H3 ALIGN="CENTER"></H3>
<H3><A NAME="Heading21"></A><FONT COLOR="#000077">Day 7</FONT></H3>
<H4 ALIGN="CENTER"><A NAME="Heading22"></A><FONT COLOR="#000077">Quiz</FONT></H4>

<DL>
	<DD><B>1. How do I initialize more than one variable in a <TT>for</TT> loop?</B><BR>
	<BR>
	Separate the initializations with commas, such as
</DL>

<PRE><FONT COLOR="#0066FF">for (x = 0, y = 10; x &lt; 100; x++, y++)
</FONT></PRE>

<DL>
	<DD><B>2. Why is <TT>goto</TT> avoided?<BR>
	</B><TT><BR>
	goto</TT> jumps in any direction to any arbitrary line of code. This makes for source
	code that is difficult to understand and therefore difficult to maintain.<BR>
	<BR>

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
风间由美性色一区二区三区| 色婷婷亚洲精品| 亚洲一区二区在线观看视频| 久久综合狠狠综合久久综合88| 91香蕉视频污在线| 国产乱色国产精品免费视频| 亚洲国产毛片aaaaa无费看| 国产偷国产偷亚洲高清人白洁| 欧美精品丝袜中出| 91蝌蚪porny| 成人国产在线观看| 国产一区在线视频| 麻豆精品在线看| 亚洲国产精品欧美一二99| 中文字幕日韩一区| 国产人成一区二区三区影院| 日韩一级片在线播放| 欧美日韩亚洲综合在线 | 欧美日韩精品福利| 国产99久久久精品| 久久成人18免费观看| 日日夜夜精品视频天天综合网| 亚洲女同一区二区| 国产精品福利影院| 国产日韩欧美一区二区三区乱码| 日韩一区二区不卡| 777色狠狠一区二区三区| 色婷婷精品久久二区二区蜜臂av| av不卡一区二区三区| 国产不卡视频在线播放| 国产传媒日韩欧美成人| 韩国三级中文字幕hd久久精品| 开心九九激情九九欧美日韩精美视频电影 | 国产精品的网站| 国产精品萝li| 亚洲欧洲色图综合| 国产精品乱人伦一区二区| 欧美激情一区二区三区| 国产欧美精品一区aⅴ影院 | 国产夜色精品一区二区av| 精品福利av导航| 久久这里只精品最新地址| 久久精品亚洲一区二区三区浴池| 久久精品视频在线看| 国产精品久久久久久久裸模| 中文字幕日韩精品一区 | 国产另类ts人妖一区二区| 国产高清亚洲一区| 成人禁用看黄a在线| av色综合久久天堂av综合| 99麻豆久久久国产精品免费优播| 91啪在线观看| 欧美区在线观看| 精品日韩一区二区| 亚洲国产精品传媒在线观看| 日韩久久一区二区| 亚洲国产综合视频在线观看| 免费精品视频在线| 粗大黑人巨茎大战欧美成人| 99久久er热在这里只有精品66| 91国内精品野花午夜精品| 91麻豆精品国产91久久久| 久久青草国产手机看片福利盒子| 国产精品免费观看视频| 亚洲自拍与偷拍| 精品一区二区三区免费毛片爱 | 91精品国产高清一区二区三区蜜臀 | 日韩在线一二三区| 国产综合一区二区| 99久久精品免费精品国产| 欧美蜜桃一区二区三区| 久久影音资源网| 亚洲三级在线免费| 麻豆一区二区在线| 99国产精品一区| 91精品国产综合久久婷婷香蕉| 欧美国产精品专区| 亚洲成av人片观看| 国产福利一区二区三区视频| 色婷婷久久久亚洲一区二区三区| 欧美刺激午夜性久久久久久久| 国产精品国产三级国产普通话蜜臀| 亚洲图片自拍偷拍| 风间由美一区二区三区在线观看 | 亚洲v中文字幕| 国产精品99久久久久久久vr| 在线观看视频一区二区| xfplay精品久久| 亚洲一区二区三区四区中文字幕| 久久99热99| 欧美色视频在线观看| 国产欧美日韩中文久久| 性欧美疯狂xxxxbbbb| 高清av一区二区| 欧美大尺度电影在线| 一区二区三区中文字幕在线观看| 久久黄色级2电影| 欧美羞羞免费网站| 中文字幕成人在线观看| 日本欧美肥老太交大片| 91精品办公室少妇高潮对白| 国产亚洲自拍一区| 秋霞成人午夜伦在线观看| 色香蕉成人二区免费| 欧美韩国日本综合| 韩国中文字幕2020精品| 91精品国产综合久久久久久久久久| 亚洲视频电影在线| 国产成人自拍网| 精品国免费一区二区三区| 婷婷开心激情综合| 欧美在线你懂得| 亚洲女同ⅹxx女同tv| 成人午夜在线视频| 国产视频不卡一区| 韩国一区二区视频| 精品免费视频一区二区| 奇米影视在线99精品| 欧美日韩另类国产亚洲欧美一级| 亚洲精品高清视频在线观看| 成人一级黄色片| 国产性色一区二区| 国产毛片精品视频| 久久综合九色综合欧美就去吻 | 成人av先锋影音| 久久精品亚洲乱码伦伦中文| 狠狠色丁香久久婷婷综| 久久亚洲精华国产精华液| 国产一区二区三区四区在线观看| 亚洲精品一区二区三区精华液 | 中文字幕av资源一区| 国产在线国偷精品产拍免费yy| 欧美一级高清片| 美日韩一级片在线观看| 欧美老年两性高潮| 亚洲va天堂va国产va久| 欧美精品 日韩| 日韩黄色一级片| 欧美成人免费网站| 国产精品综合视频| 日本一区二区三区视频视频| 国产福利一区二区三区在线视频| 亚洲国产高清不卡| 色先锋久久av资源部| 亚洲地区一二三色| 日韩女优av电影| 国产麻豆精品视频| 中文字幕在线观看一区| 99久久久国产精品免费蜜臀| 一级做a爱片久久| 欧美人xxxx| 国产乱子伦视频一区二区三区| 国产情人综合久久777777| av激情亚洲男人天堂| 一区二区三区免费网站| 欧美日韩国产在线观看| 麻豆国产91在线播放| 亚洲国产精品成人综合色在线婷婷| 91影院在线免费观看| 五月综合激情日本mⅴ| 久久综合色天天久久综合图片| 成人一区二区三区中文字幕| 夜夜嗨av一区二区三区网页| 日韩欧美国产一二三区| 成人黄色在线看| 香蕉久久一区二区不卡无毒影院| 2024国产精品| 91女人视频在线观看| 蜜臀a∨国产成人精品| 国产精品久久久久久久久免费樱桃| 色妞www精品视频| 久久99精品国产91久久来源| 最新日韩av在线| 91精品国产色综合久久久蜜香臀| 国产精品亚洲第一区在线暖暖韩国| 亚洲乱码国产乱码精品精可以看 | 亚洲色图在线看| 日韩欧美色电影| 91丨porny丨在线| 美国十次综合导航| 亚洲欧美另类久久久精品| 日韩欧美一卡二卡| 99精品欧美一区二区三区综合在线| 日韩精品一级二级 | 欧美精品一区二区精品网| 91亚洲国产成人精品一区二区三 | 91麻豆精品国产自产在线观看一区| 国产超碰在线一区| 日本最新不卡在线| 自拍偷自拍亚洲精品播放| 精品美女在线播放| 欧洲精品一区二区三区在线观看| 国产精品18久久久| 日韩黄色小视频| 亚洲精品一二三| 欧美国产激情二区三区| 欧美mv和日韩mv的网站| 欧美偷拍一区二区| 不卡大黄网站免费看| 狠狠色丁香久久婷婷综|