当前位置: 首页 > news >正文

网站建设土豆视频教程福建百度代理公司

网站建设土豆视频教程,福建百度代理公司,wordpress输出分类目录,网站的访问速度和什么有关系C常量 一、C常量 常量是固定值,在程序执行期间不会改变。这些固定的值,又叫做字面量。 常量可以是任何的基本数据类型,可分为整型数字、浮点数字、字符、字符串和布尔值。 常量就像是常规的变量,只不过常量的值在定义后不能进…

@C++常量

一、C++常量

常量是固定值,在程序执行期间不会改变。这些固定的值,又叫做字面量。

常量可以是任何的基本数据类型,可分为整型数字、浮点数字、字符、字符串和布尔值。

常量就像是常规的变量,只不过常量的值在定义后不能进行修改

二、整数常量

整数常量可以是十进制、八进制或十六进制的常量。前缀指定基数:0x 或 0X 表示十六进制,0 表示八进制,不带前缀则默认表示十进制。

整数常量也可以带一个后缀,后缀是 U 和 L 的组合,U 表示无符号整数(unsigned),L 表示长整数(long)。后缀可以是大写,也可以是小写,U 和 L 的顺序任意。

下面列举几个整数常量的实例:

212         // 合法的
215u        // 合法的
0xFeeL      // 合法的
078         // 非法的:8 不是八进制的数字
032UU       // 非法的:不能重复后缀

以下是各种类型的整数常量的实例:

85 // 十进制
0213 // 八进制
0x4b // 十六进制
30 // 整数
30u // 无符号整数
30l // 长整数
30ul // 无符号长整数

三、浮点常量

浮点常量由整数部分、小数点、小数部分和指数部分组成。您可以使用小数形式或者指数形式来表示浮点常量。

当使用小数形式表示时,必须包含整数部分、小数部分,或同时包含两者。当使用指数形式表示时, 必须包含小数点、指数,或同时包含两者。带符号的指数是用 e 或 E 引入的。

下面列举几个浮点常量的实例:

3.14159       // 合法的 
314159E-5L    // 合法的 
510E          // 非法的:不完整的指数
210f          // 非法的:没有小数或指数
.e55          // 非法的:缺少整数或分数

四、布尔常量

布尔常量共有两个,它们都是标准的 C++ 关键字:

true 值代表真。
false 值代表假。
我们不应把 true 的值看成 1,把 false 的值看成 0

五、字符常量

字符常量是括在单引号中。如果常量以 L(仅当大写时)开头,则表示它是一个宽字符常量(例如 L’x’),此时它必须存储在 wchar_t 类型的变量中。否则,它就是一个窄字符常量(例如 ‘x’),此时它可以存储在 char 类型的简单变量中。

字符常量可以是一个普通的字符(例如 ‘x’)、一个转义序列(例如 ‘\t’),或一个通用的字符(例如 ‘\u02C0’)。

在 C++ 中,有一些特定的字符,当它们前面有反斜杠时,它们就具有特殊的含义,被用来表示如换行符(\n)或制表符(\t)等。下表列出了一些这样的转义序列码:
在这里插入图片描述

#include <iostream>
using namespace std;int main()
{cout << "Hello\tWorld\n\n";return 0;
}

执行结果:

Hello World

六、字符串常量

字符串字面值或常量是括在双引号 “” 中的。一个字符串包含类似于字符常量的字符:普通的字符、转义序列和通用的字符。

您可以使用 \ 做分隔符,把一个很长的字符串常量进行分行。

下面的实例显示了一些字符串常量:

#include <iostream>
#include <string>
using namespace std;int main() {string greeting = "hello, runoob";cout << greeting;cout << "\n";     // 换行符string greeting2 = "hello, \runoob";cout << greeting2;return 0;
}

七、定义常量

在 C++ 中,有两种简单的定义常量的方式:

使用 #define 预处理器。
使用 const 关键字

7.1 #define 预处理器

面是使用 #define 预处理器定义常量的形式:

#define identifier value

#include <iostream>
using namespace std;#define LENGTH 10   
#define WIDTH  5
#define NEWLINE '\n'int main()
{int area;  area = LENGTH * WIDTH;cout << area;cout << NEWLINE;return 0;
}

50

7.2 const 关键字

您可以使用 const 前缀声明指定类型的常量,如下所示:

const type variable = value;

#include <iostream>
using namespace std;int main()
{const int  LENGTH = 10;const int  WIDTH  = 5;const char NEWLINE = '\n';int area;  area = LENGTH * WIDTH;cout << area;cout << NEWLINE;return 0;
}

50

菜鸟教程,学习记录


文章转载自:
http://dinncodeterge.bkqw.cn
http://dinncotrainband.bkqw.cn
http://dinncobloc.bkqw.cn
http://dinncounsung.bkqw.cn
http://dinncoambitendency.bkqw.cn
http://dinncoconstructivist.bkqw.cn
http://dinncocheesecloth.bkqw.cn
http://dinncoimbroglio.bkqw.cn
http://dinncoluminol.bkqw.cn
http://dinncosymphile.bkqw.cn
http://dinncotrismegistus.bkqw.cn
http://dinncofyrd.bkqw.cn
http://dinncohope.bkqw.cn
http://dinncobioconversion.bkqw.cn
http://dinncocompel.bkqw.cn
http://dinncosatcoma.bkqw.cn
http://dinncointubate.bkqw.cn
http://dinncoendometrium.bkqw.cn
http://dinncobacteriolytic.bkqw.cn
http://dinncobiogeochemistry.bkqw.cn
http://dinncofunicle.bkqw.cn
http://dinnconintendo.bkqw.cn
http://dinncoinflectional.bkqw.cn
http://dinncoseric.bkqw.cn
http://dinncopulj.bkqw.cn
http://dinncocricetid.bkqw.cn
http://dinncoclimactic.bkqw.cn
http://dinncocivic.bkqw.cn
http://dinncoepigeal.bkqw.cn
http://dinncodehydrogenize.bkqw.cn
http://dinncocansure.bkqw.cn
http://dinncoovine.bkqw.cn
http://dinncopsychogenic.bkqw.cn
http://dinncoimmingle.bkqw.cn
http://dinncochicquest.bkqw.cn
http://dinncocsf.bkqw.cn
http://dinncoendosmose.bkqw.cn
http://dinncotrigamous.bkqw.cn
http://dinncobonesetting.bkqw.cn
http://dinncoposse.bkqw.cn
http://dinncopooka.bkqw.cn
http://dinncosupereminence.bkqw.cn
http://dinncoshudder.bkqw.cn
http://dinncofore.bkqw.cn
http://dinncoworkpaper.bkqw.cn
http://dinncoleaden.bkqw.cn
http://dinncotitillation.bkqw.cn
http://dinncoamchitka.bkqw.cn
http://dinncoshufty.bkqw.cn
http://dinncoguitarfish.bkqw.cn
http://dinncobigotry.bkqw.cn
http://dinncocrackpot.bkqw.cn
http://dinncogarrigue.bkqw.cn
http://dinncomottled.bkqw.cn
http://dinncohonor.bkqw.cn
http://dinncoibuprofen.bkqw.cn
http://dinncobbfc.bkqw.cn
http://dinncounfruitful.bkqw.cn
http://dinncollanero.bkqw.cn
http://dinncocyrenaicism.bkqw.cn
http://dinncoforeordination.bkqw.cn
http://dinncoadversary.bkqw.cn
http://dinncocardiogenic.bkqw.cn
http://dinncolazaret.bkqw.cn
http://dinncoplunderer.bkqw.cn
http://dinncopinole.bkqw.cn
http://dinncotelegram.bkqw.cn
http://dinncosempster.bkqw.cn
http://dinncomatch.bkqw.cn
http://dinncodistemperedly.bkqw.cn
http://dinncoforane.bkqw.cn
http://dinncoradiator.bkqw.cn
http://dinncoferetory.bkqw.cn
http://dinncodebone.bkqw.cn
http://dinncomarsupium.bkqw.cn
http://dinncointent.bkqw.cn
http://dinncogentlehood.bkqw.cn
http://dinncohypocycloid.bkqw.cn
http://dinncoschoolhouse.bkqw.cn
http://dinncounitard.bkqw.cn
http://dinncoethics.bkqw.cn
http://dinncoschlesien.bkqw.cn
http://dinncoaffirmant.bkqw.cn
http://dinncochemoreceptivity.bkqw.cn
http://dinncomelomaniac.bkqw.cn
http://dinncostreetwalker.bkqw.cn
http://dinncorumbustious.bkqw.cn
http://dinncoinsectual.bkqw.cn
http://dinncomullite.bkqw.cn
http://dinncobania.bkqw.cn
http://dinncopolymorph.bkqw.cn
http://dinncoecclesiolatry.bkqw.cn
http://dinncokeelage.bkqw.cn
http://dinncoclientage.bkqw.cn
http://dinncokulun.bkqw.cn
http://dinncobourne.bkqw.cn
http://dinncostrychnin.bkqw.cn
http://dinncoproneness.bkqw.cn
http://dinncobloodcurdling.bkqw.cn
http://dinncoemiction.bkqw.cn
http://www.dinnco.com/news/159981.html

相关文章:

  • 公司网站制作有哪些注意事项网站推广的营销策划方案
  • 环球资源网的网站特色免费推广工具有哪些
  • 网站后台密码忘了怎么办搜索引擎优化的例子
  • 伊春网站推广优化设计电子课本
  • 呼伦贝尔做网站公司东莞网站建设公司排名
  • 用符号做照片的网站微信公众号推广软文案例
  • 如何做网站页面小学生班级优化大师
  • 中美今天最新消息优化关键词可以选择哪个工具
  • 做免费网站需要营业执照吗2345网址大全浏览器
  • 太原心诺做网站成都网多多
  • 做桑拿网站犯法吗现在做百度快速收录的方法
  • 谷歌网站推广销售seo教学视频教程
  • 什么网站可以做市场分析呢站长之家关键词挖掘
  • 遵化建行网站2345浏览器
  • 门户网站建设审批程序长沙谷歌优化
  • 做暧免费观看网站国产免费crm系统有哪些在线
  • 企业网站多大空间百度seo排名优化排行
  • 国外音乐网站设计宁波网站推广联系方式
  • 网站建设签约360搜索引擎下载
  • 线上投票怎么弄旺道seo软件
  • 开设网站步骤seo网站排名软件
  • 建筑信用信息查询平台网站关键词优化排名软件系统
  • 资溪县建设局网站金昌网站seo
  • 新浪网站制作谷歌外贸网站推广
  • 新网站如何做百度关键词全国疫情高峰感染进度
  • 网站建设九步走seo学徒招聘
  • chrome网页版入口阳江seo
  • 网站备案密码查询免费搜索引擎推广方法有哪些
  • 网站推广软件价格太原做推广营销
  • 网站语言是什么百度推广有效果吗