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

你可能感兴趣的文章
Vue过渡 & 动画---vue工作笔记0014
查看>>
Netty 异步任务调度与异步线程池
查看>>
Netty 的 Handler 链调用机制
查看>>
Netty 编解码器和 Handler 调用机制
查看>>
Netty 编解码器详解
查看>>
Netty 解决TCP粘包/半包使用
查看>>
Netty 调用,效率这么低还用啥?
查看>>
Netty 高性能架构设计
查看>>
Netty+Protostuff实现单机压测秒级接收35万个对象实践经验分享
查看>>
Netty+SpringBoot+FastDFS+Html5实现聊天App详解(一)
查看>>
netty--helloword程序
查看>>
netty2---服务端和客户端
查看>>
Netty5.x 和3.x、4.x的区别及注意事项(官方翻译)
查看>>
netty——bytebuf的创建、内存分配与池化、组成、扩容规则、写入读取、内存回收、零拷贝
查看>>
netty——Channl的常用方法、ChannelFuture、CloseFuture
查看>>
netty——EventLoop概念、处理普通任务定时任务、处理io事件、EventLoopGroup
查看>>
netty——Future和Promise的使用 线程间的通信
查看>>
netty——Handler和pipeline
查看>>
Vue输出HTML
查看>>
netty——黏包半包的解决方案、滑动窗口的概念
查看>>