📄 10.6.htm
字号:
<html>
<head>
<title>编译原理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link type="text/css" rel="stylesheet" href="../css/specification.css">
</head>
<BODY>
<table align=right width=300>
<tr>
<td>
<img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='10.5.1.htm'" ></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='10.6b.htm'" ></img></td>
</tr>
</table>
<br><br>
<font class="title2"><b>练习</b></font>
<table><tr><td>    </td>
<td class="content">
<b>10.1</b> 程序10.1给出了乐器类库的一个片断。根据10.2.2节的编译方案,确定该程序中定义的对象flute的动态方法表。</p>
<font color="#0000FF">enum</font> note { middleC, Csharp, Cflat };<br>
<font color="#0000FF">class</font> instrument{<br>
<font color="#0000FF">public</font>:<br>
<font color="#0000FF"> virtual</font>
<font color="#0000FF">void</font> play(note) {<br>
<font color="#0000FF"> cout</font><<"instrument::play"<<endl;<br><<font color="#0000FF">endl</font>;<br> }<br>
};<br>
<font color="#0000FF">class</font> wind : <font color="#0000FF">public</font> instrument{<br>
<font color="#0000FF">public</font>:<br>
<font color="#0000FF">void</font> play(note) {<br>
<font color="#0000FF">cout</font><<"wind::play"<<endl;<br><<font color="#0000FF">endl;</font><br>
};<br>
<font color="#0000FF">void</font> tune(instrument & i){v <font color="#008000">//…</font><br>
i.play(middleC);<br>
}<br>
<font color="#0000FF">main</font>()<br>
{<br>
wind flute;<br>
tune(flute);<br>
}<p align="center"><b>程序10.1<br>
</b></p>
<table align=center width=70%>
<tr><td align=right>
<img src="../images/key.gif" onmouseover="javascript:style.cursor='hand'" onclick="javascript:window.open('10.6.1.htm','','left=500,top=400,toolbar=no,scrollbars=no,width=250,height=100')" width="32" height="32"></img>
</td></tr>
</table>
<a name="10.2"></a>
<hr size=2 align=center color=red><br>
<b>10.2</b> <span style="font-family: 宋体">确定程序</span><span lang="EN-US">1.1</span><span style="font-family: 宋体">中对</span><span lang="EN-US">tune(flute)</span><span style="font-family: 宋体">的编译形式,并指出该函数的运行结果。</span><table align=center width=70%>
<tr><td align=right>
<img src="../images/key.gif" onmouseover="javascript:style.cursor='hand'" onclick="javascript:window.open('10.6.2.htm','','left=500,top=400,toolbar=no,width=500,height=200')" width="32" height="32"></img>
</td></tr>
</table>
<hr size=2 align=center color=red>
<table align=center width=70%>
<tr><td align=right>
</td></tr>
</table>
<br>
<table align=right width=300>
<tr>
<td>
<img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='10.5.1.htm'" ></img></td>
<td>
<img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'" onclick="vbscript:window.location.href='10.6b.htm'" ></img></td>
</tr>
</table>
</BODY>
</html>
<html><script language="JavaScript">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -