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

📄 10.2.2c.htm

📁 建立《编译原理网络课程》的目的不仅使学生掌握构造编译程序的原理和技术
💻 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.2.2b.htm'" ></td>
    <td>
    <img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'"
    onclick="vbscript:window.location.href='10.3.1.htm'" ></imag></td>
  </tr>
</table>

<p> </p>
<table>
<tr>
<td>&nbsp&nbsp&nbsp&nbsp</td>
<td class="content">
<p>
当定义一个对象时,我们会在对象的起始地址处插入一个指针指向该对象所在类的动态方法表,这个指针在c++中也被称为虚指针。有了这些准备,当编译c.f()时,就会生成以下的指令:
<p>
1. 在对象c的起始地址取得虚指针;
<p>
2. 从虚指针指向的动态方法表对应的f所在的偏移量处(这是一个常量)获得机器标号p;
<p>
3. 跳转到地址p处继续执行,并保存返回结果。
<p>
根据上面属性和方法的编译方案,程序10.5对应的对象实例如图10.6所示
<p align=center><img src="images/10_6.gif"></p>
</td>
</tr>
</table>

<p> </p>

<table align="right" width="300">
  <tr>
    <td>
    <img src="../images/previous.gif" onmouseover="javascript:style.cursor='hand'"
    onclick="vbscript:window.location.href='10.2.2b.htm'" ></td>
    <td>
    <img src="../images/next.gif" onmouseover="javascript:style.cursor='hand'"
    onclick="vbscript:window.location.href='10.3.1.htm'" ></imag></td>
  </tr>
</table>
</body>
</html>
<html><script language="JavaScript">

⌨️ 快捷键说明

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