📄 page_784.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>page_784</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_783.html">< previous page</a></td> <td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_784</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_785.html">next page ></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 784</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="Courier New, Courier, Mono New, Courier, Mono" size="2">struct聽DateType<br />{<br />聽聽聽聽int聽month;聽聽//聽Assume聽1..12<br />聽聽聽聽int聽day;聽聽聽聽//聽Assume聽1..31<br />聽聽聽聽int聽year;聽聽聽//聽Assume聽1900..2050<br />};<br />struct聽StatisticsType<br />{<br />聽聽聽聽float聽聽聽聽failRate;<br />聽聽聽聽DateType聽lastServiced;<br />聽聽聽聽int聽聽聽聽聽聽downDays;<br />};<br />struct聽MachineRec<br />{<br />聽聽聽聽int聽聽聽聽聽聽聽聽聽聽聽idNumber;<br />聽聽聽聽String50聽聽聽聽聽聽description;<br />聽聽聽聽StatisticsType聽history;<br />聽聽聽聽DateType聽聽聽聽聽聽聽purchaseDate;<br />聽聽聽聽float聽聽聽聽聽聽聽聽聽聽cost;<br />};<br /><br />MachineRec聽inventory[NUM_MACHINES];<br />MachineRec聽machine;<br />int聽聽聽聽聽聽聽聽counter;</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">The contents of a machine record are now much more obvious. Two of the components of the </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">struct</font><font face="Times New Roman, Times, Serif" size="3"> type </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">MachineRec</font><font face="Times New Roman, Times, Serif" size="3"> are themselves </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">structs</font><font face="Times New Roman, Times, Serif" size="3">: </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">purchaseDate</font><font face="Times New Roman, Times, Serif" size="3"> is of </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">struct</font><font face="Times New Roman, Times, Serif" size="3"> type </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">DateType</font><font face="Times New Roman, Times, Serif" size="3">, and </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">history</font><font face="Times New Roman, Times, Serif" size="3"> is of </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">struct</font><font face="Times New Roman, Times, Serif" size="3"> type </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">StatisticsType</font><font face="Times New Roman, Times, Serif" size="3">. One of the components of </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">struct</font><font face="Times New Roman, Times, Serif" size="3"> type </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">StatisticsType</font><font face="Times New Roman, Times, Serif" size="3"> is a </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">struct</font><font face="Times New Roman, Times, Serif" size="3"> of type </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">DateType</font><font face="Times New Roman, Times, Serif" size="3">.</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">How do we access a hierarchical structure such as this one? We build the accessing expressions (member selectors) for the members of the embedded </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">structs</font><font face="Times New Roman, Times, Serif" size="3"> from left to right, beginning with the </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">struct</font><font face="Times New Roman, Times, Serif" size="3"> variable name. Following are some expressions and the components they access.</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td height="12"></td></tr><tr><td><table cellspacing="0" width="632" cellpadding="7"><tr><td valign="top"><font face="Times New Roman, Times, Serif" size="2"><i>Expression</i></font></td><td valign="top"><font face="Times New Roman, Times, Serif" size="2"><i>Component Accessed</i></font></td></tr><tr><td valign="top"><font face="Times New Roman, Times, Serif" size="2"></font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">machine.purchaseDate</font></td><td valign="top"><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">DateType聽struct</font><font face="Times New Roman, Times, Serif" size="2"> variable</font></td></tr><tr><td valign="top"><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">machine.purchaseDate.month</font></td><td valign="top"><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">month</font><font face="Times New Roman, Times, Serif" size="2"> member of a </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">DateType聽struct</font><font face="Times New Roman, Times, Serif" size="2"> variable</font></td></tr><tr><td valign="top"><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">machine.purchaseDate.year</font></td><td valign="top"><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">year</font><font face="Times New Roman, Times, Serif" size="2"> member of a </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">DateType聽struct</font><font face="Times New Roman, Times, Serif" size="2"> variable</font></td></tr><tr><td valign="top"><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">machine.history.lastServiced.year</font></td><td valign="top"><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">year</font><font face="Times New Roman, Times, Serif" size="2">member of a </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">DateType聽struct</font><font face="Times New Roman, Times, Serif" size="2"> variable contained in a </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">struct</font><font face="Times New Roman, Times, Serif" size="2"> of type </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">StatisticsType</font></td></tr></table></td></tr></table><br /><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">Figure 14-4 is a pictorial representation of </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">machine</font><font face="Times New Roman, Times, Serif" size="3"> with values. Look carefully at how each component is accessed.</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_783.html">< previous page</a></td> <td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_784</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_785.html">next page ></a></td> </tr> </table> </body> </html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -