⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 page_959.html

📁 Programming and Problem Solving with C++
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">	<html>		<head>			<title>page_959</title>			<link rel="stylesheet" href="reset.css" type="text/css" media="all">			<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />		</head>		<body>		<table summary="top nav" border="0" width="100%">			<tr>				<td align="left" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_958.html">&lt;&nbsp;previous page</a></td>				<td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_959</strong></td>				<td align="right" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_960.html">next page&nbsp;&gt;</a></td>			</tr>					<tr>				<td align="left" colspan="3" style="background: #ffffff; padding: 20px;">    <table border="0" width="100%" cellpadding="0"><tr><td align="center">  <table border="0" cellpadding="2" cellspacing="0" width="100%"><tr><td align="left"></td>  <td align="right"></td>  </tr></table></td></tr><tr><td align="left"><p></p><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td align="right"><font face="Times New Roman, Times, Serif" size="2" color="#FF0000">Page 959</font></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td>  <td colspan="3" height="12"></td>  <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td>  <td><font face="Times New Roman, Times, Serif" size="3"><i>Quick Check</i></font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td>  <td colspan="3" height="12"></td>  <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td>  <td><font face="Times New Roman, Times, Serif" size="3">1. Fill in the blanks: Structured (procedural) programming results in a program that is a collection of interacting ______, whereas OOP results in a program that is a collection of interacting ______. (pp. 906909)</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td>  <td colspan="3" height="12"></td>  <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td>  <td><font face="Times New Roman, Times, Serif" size="3">2. Name the three language features that characterize object-oriented programming languages. (pp. 906909)</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td>  <td colspan="3" height="12"></td>  <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td>  <td><font face="Times New Roman, Times, Serif" size="3">3. Given the </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">class</font><font face="Times New Roman, Times, Serif" size="3"> declaration</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td>  <td colspan="3" height="12"></td>  <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td>  <td><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">class聽Point<br />{<br />public:<br />聽聽聽聽int聽X_Coord()聽const;聽聽聽聽聽聽聽聽聽聽聽//聽Return聽the聽x-coordinate<br />聽聽聽聽int聽Y_Coord()聽const;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽//聽Return聽the聽y-coordinate<br />聽聽聽聽Point(聽/*聽in聽*/聽int聽initX,聽聽聽聽聽//聽Constructor<br />聽聽聽聽聽聽聽聽聽聽聽/*聽in聽*/聽int聽initY聽);<br />private:<br />聽聽聽聽int聽x;<br />聽聽聽聽int聽y;<br />};</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"><img src="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" border="0" width="29" height="1" alt="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" /></td>  <td colspan="3" height="12"></td>  <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td>  <td><font face="Times New Roman, Times, Serif" size="3">and the type declaration</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td>  <td colspan="3" height="12"></td>  <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td>  <td><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">enum聽StatusType聽{ON,聽OFF};</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"><img src="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" border="0" width="29" height="1" alt="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" /></td>  <td colspan="3" height="12"></td>  <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td>  <td><font face="Times New Roman, Times, Serif" size="3">declare a class Pixel that inherits from class </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">Point</font><font face="Times New Roman, Times, Serif" size="3">. Class </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">Pixel</font><font face="Times New Roman, Times, Serif" size="3"> has an additional data member of type </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">StatusType</font><font face="Times New Roman, Times, Serif" size="3"> named </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">status</font><font face="Times New Roman, Times, Serif" size="3">; it has an additional member function </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">CurrentStatus</font><font face="Times New Roman, Times, Serif" size="3"> that returns the value of </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">status</font><font face="Times New Roman, Times, Serif" size="3">; and it supplies its own constructor that receives three parameters. (pp. 909917)</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td>  <td colspan="3" height="12"></td>  <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td>  <td><font face="Times New Roman, Times, Serif" size="3">4. Write a client statement that creates a </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">Pixel</font><font face="Times New Roman, Times, Serif" size="3"> object named one</font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">Pixel</font><font face="Times New Roman, Times, Serif" size="3"> with an initial (<i>X, Y)</i> position of (3, 8) and a status of </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">OFF</font><font face="Times New Roman, Times, Serif" size="3">. (pp. 909917)</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td>  <td colspan="3" height="12"></td>  <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td>  <td><font face="Times New Roman, Times, Serif" size="3">5. Assuming </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">somePixel</font><font face="Times New Roman, Times, Serif" size="3"> is an object of type </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">Pixel</font><font face="Times New Roman, Times, Serif" size="3">, write client code that prints out the current <i>x-</i>and <i>y-</i>coordinates and status of </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">somePixel</font><font face="Times New Roman, Times, Serif" size="3">. (pp. 909917)</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td>  <td colspan="3" height="12"></td>  <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td>  <td><font face="Times New Roman, Times, Serif" size="3">6. Write the function definitions for the </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">Pixel</font><font face="Times New Roman, Times, Serif" size="3"> class constructor and the </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">CurrentStatus</font><font face="Times New Roman, Times, Serif" size="3"> function. (pp. 917920)</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td>  <td colspan="3" height="12"></td>  <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td>  <td><font face="Times New Roman, Times, Serif" size="3">7. Fill in the private part of the following class declaration, which uses composition to define a </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">Line</font><font face="Times New Roman, Times, Serif" size="3"> object in terms of two </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">Point</font><font face="Times New Roman, Times, Serif" size="3"> objects. (pp. 921922)</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td>  <td colspan="3" height="12"></td>  <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td>  <td><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">class聽Line<br />{<br />public:<br />聽聽聽聽Point聽StartingPoint()聽const;聽聽聽//聽Return聽line's聽starting聽point<br />聽聽聽聽Point聽EndingPoint()聽const;聽聽聽聽聽//聽Return聽line's聽ending聽point<br />聽聽聽聽float聽Length()聽const;聽聽聽聽聽聽聽聽聽聽//聽Return聽length聽of聽the聽line<br />聽聽聽聽Line(聽/*聽in聽*/聽int聽startX,聽聽聽聽聽//聽Constructor<br />聽聽聽聽聽聽聽聽聽聽/*聽in聽*/聽int聽startY,<br /></font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table></td></tr></table><p><font size="0"></font></p>  </td>			</tr>				<tr>				<td align="left" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_958.html">&lt;&nbsp;previous page</a></td>				<td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_959</strong></td>				<td align="right" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_960.html">next page&nbsp;&gt;</a></td>			</tr>		</table>		</body>	</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -