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

📄 right1-2.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>第 1 章</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: 8; top: -9"><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">第 1 章</span><span style="background-color: #CCFF99">&nbsp;              
</span>&gt;<span style="background-color: #CCFF99"> 第 1 节 </span>&gt;<span style="background-color: #CCFF99"> 
1.2 常量和变量</span></p>          
<hr color="#008000" size="1">

<p align="left" class="右内容" style="text-indent: 0; margin: 0"> </p>

<font SIZE="3">
<p align="left" style="text-indent: 0; line-height: 150%; margin: 0"></font><font FACE="??ì?,SimSun" LANG="ZH-CN" size="2">1.              
常量&nbsp;</font></p>
<p align="left" style="text-indent: 0; line-height: 150%; margin: 0"><font FACE="??ì?,SimSun" LANG="ZH-CN" size="2">常量是在程序中不能被改变的量。常量有各种不同的数据类型,不同数据类型的常量由它的表示方法决定,常量被存储在不能被修改的匿名变量中,常量或常量符号可出现在表达式中。</font></p>
<blockquote>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font FACE="oúì?,SimHei" LANG="ZH-CN" size="2">(1) 整型常量&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;              
234,0378,0x7A</font></p>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font FACE="oúì?,SimHei" LANG="ZH-CN" size="2">(2) 浮点型常量&nbsp;&nbsp;&nbsp;              
3.2f, 76.4L</font></p>             
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font FACE="oúì?,SimHei" LANG="ZH-CN" size="2">(3) 字符常量&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;              
'a','x','*','A'&nbsp;&nbsp;</font></p>
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font FACE="oúì?,SimHei" LANG="ZH-CN" size="2">(4) 字符串常量&nbsp;&nbsp;&nbsp;              
&quot;How are you?&quot;</font></p>             
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font FACE="oúì?,SimHei" LANG="ZH-CN" size="2">(5) 枚举常量&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;              
enum day {sun, mon, tue, wed, thu, fri, sat} ; //定义枚举类型</font></p>             
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font face="oúì?,SimHei" lang="ZH-CN" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       
&nbsp;day d1,d2,d3 //定义枚举常量</font></p>             
<p style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font FACE="oúì?,SimHei" LANG="ZH-CN" size="2">(6) 符号常量&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;       
const float pi=3.1415926&nbsp; //定义符号常量</font></p>             
  <blockquote>
    <font SIZE="1">
    </blockquote>
  </blockquote>
</font>
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">2. </font><font FACE="??ì?,SimSun" LANG="ZH-CN"><font size="2">变量</font></p>            
</font><font SIZE="3">
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"></font><font FACE="??ì?,SimSun" LANG="ZH-CN" size="2">变量是在程序执行中其值是可以变化的量。变量有三个要素:名字、类型和值。</font></p>
<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font FACE="oúì?,SimHei" LANG="ZH-CN" size="2">变量的定义与初始化:</font><font size="2"><font FACE="??ì?,SimSun" LANG="ZH-CN">在</font>C++<font FACE="??ì?,SimSun" LANG="ZH-CN">中,任何一个变量在被引用之前必须被定义。</font>C++<font FACE="??ì?,SimSun" LANG="ZH-CN">中变量可以在程序中随时定义,不必集中在程序前。</font></font></p>

<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2"><font FACE="??ì?,SimSun" LANG="ZH-CN">定义变量的格式为:</font><font LANG="ZH-CN" color="#008000">类型&nbsp;      
变量名表</font></font></p>

<p ALIGN="JUSTIFY" style="line-height: 150%; margin-top: 0; margin-bottom: 0"> </p>

<p ALIGN="justify" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">3.           
typedef</font></p>
<p ALIGN="justify" style="line-height: 150%; margin-top: 0; margin-bottom: 0"><font size="2">typedef<font FACE="??ì?,SimSun" LANG="ZH-CN">用来为已存在的类型名提供一个同义词。其语法格式为:</font></font></p>
<p ALIGN="justify" style="line-height: 200%; margin-top: 0; margin-bottom: 0"><font size="2" color="#008000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
typedef           
<font FACE="??ì?,SimSun" LANG="ZH-CN">数据类型名</font> <font FACE="??ì?,SimSun" LANG="ZH-CN">新数据类型名;</font></font></p>         
<font SIZE="3">
<p ALIGN="justify" style="line-height: 100%; margin-top: 0; margin-bottom: 0"></font><font FACE="??ì?,SimSun" LANG="ZH-CN" size="2">例如:</font><font size="2">typedef          
unsigned int UINT;</font> </p>       

<hr size="1" color="#008000">
<p>&nbsp;<span style="position: absolute; left: 33; top: 625"><a href="right1-1.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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      
<span style="position: absolute; left: 502; top: 631"><a href="right1-3.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 + -