博客
关于我
C++ Primer 5th笔记(2)chapter 2变量和基本类型:变量声明、关键字
阅读量:60 次
发布时间:2019-02-26

本文共 991 字,大约阅读时间需要 3 分钟。

0. 几个零星知识点

. 嵌套作用域:局部变量会覆盖全局变量

. char 在有些机器有符号,有的无符号。
. 标识符大小写敏感。

1.变量声明和定义

c++ 将声明和定义分开来。

声明 extern int i;// 指定变量名字、类型

定义 extern double pi = 3.45; //申请存储空间、为变量赋初值

变量可以声明多次,定义一次.

eg.

shareVariable.h

#ifndef SHAREVARIABLE_H #define SHAREVARIABLE_H  extern int nShare;// 指定变量名字、类型#endif

useShareVariable1.h

#ifndef USESHAREVARIABLE1_H #define USESHAREVARIABLE1_H  #include 
#include "shareVariable.h"extern int nShare = 1;// 定义变量class useShareVariable1 { public: void static test() { std::cout << nShare; }};#endif

useShareVariable2.h

#ifndef USESHAREVARIABLE2_H #define USESHAREVARIABLE2_H  #include 
#include "shareVariable.h" extern int nShare;//声明变量,该句也可以忽略class useShareVariable2 { public: void static test() { std::cout << nShare; }};#endif

2. c++关键字

在这里插入图片描述

我不认识的:decltype

asm
constexpr
const_cast
mutable
noexcept
thread_local
static_cast
staitic_assert
reinterpret_cast
volatile

3. c++操作符替代名

在这里插入图片描述

参考

[1]: 代码 https://github.com/thefistlei/cplusprimer/tree/main/cprimer

转载地址:http://jbuz.baihongyu.com/

你可能感兴趣的文章
mysql的常见八股文面试题
查看>>
MySQL的常见命令
查看>>
MySQL的操作:
查看>>
mysql的数据类型有哪些?
查看>>
mysql的语法规范
查看>>
mysql的配置文件参数
查看>>
MySQL的错误:No query specified
查看>>
MySQL相关命令
查看>>
mysql社工库搭建教程_社工库的搭建思路与代码实现
查看>>
MySQL简单查询
查看>>
mysql类型转换函数convert与cast的用法
查看>>
mysql系列一
查看>>
MySQL系列之数据类型(Date&Time)
查看>>
mysql索引
查看>>
mysql索引
查看>>
Mysql索引,索引的优化,如何避免索引失效案例
查看>>
mysql索引、索引优化(这一篇包括所有)
查看>>
MySql索引为什么使用B+树
查看>>
WARNING!VisualDDK wizard was unable to find any DDK/WDK installed on your system.
查看>>
Mysql索引优化
查看>>