博客
关于我
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/

你可能感兴趣的文章
Netty工作笔记0060---Tcp长连接和短连接_Http长连接和短连接_UDP长连接和短连接
查看>>
Netty工作笔记0061---Netty心跳处理器编写
查看>>
Netty工作笔记0062---WebSocket长连接开发
查看>>
Netty工作笔记0063---WebSocket长连接开发2
查看>>
vue样式穿透 ::v-deep的具体使用
查看>>
Netty工作笔记0065---WebSocket长连接开发4
查看>>
Netty工作笔记0066---Netty核心模块内容梳理
查看>>
Vue基本使用---vue工作笔记0002
查看>>
Netty工作笔记0068---Protobuf机制简述
查看>>
Netty工作笔记0069---Protobuf使用案例
查看>>
Netty工作笔记0070---Protobuf使用案例Codec使用
查看>>
Netty工作笔记0071---Protobuf传输多种类型
查看>>
Netty工作笔记0072---Protobuf内容小结
查看>>
Netty工作笔记0073---Neety的出站和入站机制
查看>>
Netty工作笔记0074---handler链调用机制实例1
查看>>
Netty工作笔记0075---handler链调用机制实例1
查看>>
Netty工作笔记0076---handler链调用机制实例3
查看>>
Netty工作笔记0077---handler链调用机制实例4
查看>>
Netty工作笔记0078---Netty其他常用编解码器
查看>>
Netty工作笔记0079---Log4j整合到Netty
查看>>