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

📄 right3-1.htm

📁 Visual C++面向对象程序设计教程(配套习题资源)
💻 HTM
字号:
<html>

<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>第 3 章</title>
<base target="rbottom">
<style>
<!--
.右标题   { font-size: 10pt; color: #000080; text-indent: 0; margin: 0 }
.右内容   { font-size: 10pt; text-align: left; text-indent: 0; line-height: 100%; margin: 
               0 }
-->
</style>
</head>

<body>

<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"> </p>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"><span style="position: absolute; left: 4; top: -8"><img border="0" src="1.gif" width="63" height="70"></span></p>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p style="line-height: 100%; text-indent: 0; margin: 0" class="右标题" align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                         
&nbsp;&nbsp;&nbsp; <span style="background-color: #CCFF99">第 3 章</span><span style="background-color: #CCFF99">&nbsp;                       
</span>&gt;<span style="background-color: #CCFF99"> 第 1 节 </span>&gt;<span style="background-color: #CCFF99">     
 3.1 面向对象程序设计</span></p>          
<hr color="#008000" size="1">

<p style="line-height: 100%; text-indent: 0; margin: 0" class="右标题" align="left"> </p>
<p style="line-height: 150%; text-indent: 0; margin: 0" class="右标题" align="left"><font lang="ZH-CN" size="2">面向对象方法将数据及对数据的操作方法放在一起,作为一个相互依存、不可分离的整体--对象,对同类型的对象抽象出其共性形成类。类中的大多数数据,只能用本类的方法进行处理。类通过一个简单的外部接口与外界发生关系,对象与对象之间通过消息进行通信。</font></p>
<p style="line-height: 200%; text-indent: 0; margin: 0" align="left"><font LANG="ZH-CN" size="2">1.   
对象</font></p>
<p style="line-height: 100%; text-indent: 0; margin: 0" align="left"><font LANG="ZH-CN" size="2">面向对象程序设计中的对象是用来描述客观事物的一个实体。</font></p>
<p style="line-height: 100%; text-indent: 0; margin: 0" align="left"><font LANG="ZH-CN" size="2">对象由一组属性和一组行为构成。</font></p>
<p style="line-height: 100%; text-indent: 0; margin: 0" align="left"><font LANG="ZH-CN" size="2">属性是用来描述对象静态特征的数据项,行为是用来描述对象动态特征的操作序列。</font></p>
<p style="line-height: 200%; text-indent: 0; margin: 0" align="left"><font LANG="ZH-CN" size="2">2.   
类</font></p>
<p style="line-height: 100%; text-indent: 0; margin: 0" align="left"><font LANG="ZH-CN" size="2">面向对象方法中的“类”,是具有相同属性和行为的一组对象的集合。</font></p>
<p style="line-height: 100%; text-indent: 0; margin: 0" align="left"><font LANG="ZH-CN" size="2">它为属于该类的全部对象提供了抽象的描述,包括属性和行为两个部分。</font></p>
<p style="line-height: 100%; text-indent: 0; margin: 0" align="left"><font LANG="ZH-CN" size="2">类与对象的关系犹如模具与铸件之间的关系,一个属于某类的对象称为该类的一个实例。</font></p>
<p style="line-height: 200%; text-indent: 0; margin: 0" align="left"><font LANG="ZH-CN" size="2">3.   
封装</font></p>
<p style="line-height: 100%; text-indent: 0; margin: 0" align="left"><font LANG="ZH-CN" size="2">封装是面向对象方法的一个重要原则,就是把隐藏的属性和行为结合成一个独立的系统单位,并尽可能隐蔽对象的内部细节。</font></p>
<p style="line-height: 100%; text-indent: 0; margin: 0" align="left"><font LANG="ZH-CN" size="2">这里有两个含义:第一个含义是把对象的全部属性和全部行为结合在一起,形成一个不可分割的独立单位;</font></p>
<p style="line-height: 100%; text-indent: 0; margin: 0" align="left"><font LANG="ZH-CN" size="2">第二个含义也称作“信息隐蔽”,即尽可能隐蔽对象的内部细节,对外形成一个边界(或者说一道屏障),只保留有限的对外接口使之与外部发生联系。</font></p>
<p ALIGN="justify" style="line-height: 200%; margin-top: 0; margin-bottom: 0"><font LANG="ZH-CN" size="2">4.   
继承</font></p>
<font SIZE="3">
<p ALIGN="JUSTIFY" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font LANG="ZH-CN" size="2">继承实现了更高层次的代码重用,是面向对象技术能够提高软件开发效率的重要原因之一,其定义是:特殊类的对象拥有其一般类的全部属性与服务,称作特殊类对一般类的继承。</font></p>
<p style="line-height: 100%; text-indent: 0; margin: 0" align="left"><font LANG="ZH-CN" size="2">继承对于软件复用有着重要意义,特殊类继承一般类,特殊类除了具有一般类的属性和行为,还可以根据具体情况增加相应的属性和行为,<font color="#FF6600">注意增加了属性和行为实际上是对一般类进行了限制。</font></font></p>
<p ALIGN="justify" style="line-height: 200%; margin-top: 0; margin-bottom: 0"><font LANG="ZH-CN" size="2">5.   
多态</font></p>
<font SIZE="3">
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font LANG="ZH-CN" size="2">多态性是指在一般类中定义的属性或行为,被特殊类继承之后,可以具有不同的数据类型或表现出不同的行为。</font></p>
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0"><font LANG="ZH-CN" size="2">这使得同一个属性或行为在一般类及其各个特殊类中具有不同的语义。</font></p>
<p style="line-height: 100%; text-indent: 0; margin: 0" align="left"><font size="2"><font LANG="ZH-CN">在</font>C++<font LANG="ZH-CN">中,多态的实现使用虚函数,在一般类中定义一个虚函数,在特殊类(派生类)中重写此代码,从而实现不同的特殊类有不同的行为。</font></font></p>

<hr size="1" color="#008000">
<p style="line-height: 100%; margin-top: 0; margin-bottom: 0">&nbsp;&nbsp; <span style="position: absolute; left: 33; top: 618"><a href="right2-7.htm" target="_self"><img border="0" src="rightd1.gif" width="113" height="70"></a></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="position: absolute; left: 486; top: 619"><a href="right3-2.htm" target="_self"><img border="0" src="rightd2.gif" width="124" height="63"></a></span></p>    

</body>

</html>

⌨️ 快捷键说明

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