当前位置:网站首页>Lesson 25 static member variables of classes
Lesson 25 static member variables of classes
2022-04-23 12:07:00 【Night rain】
Lesson 25 Static member variable of class
List of articles
One 、 review
- Access to... By name public Member variables
- The variables of each object are exclusive
- Member variables cannot be shared between objects
Two 、 Static member variable
- stay C++ Static member variables can be defined in
- Static member variables belong to the entire class
- The life cycle of a static member variable does not depend on any object
- Common static member variables can be accessed directly through the class name
- All objects share static member variables of the class
- Common static member variables can be accessed through object names
characteristic
- Directly through when defining static Keyword modification
- Static member variables need to allocate space outside the class
- Static member variables are located in the global data area inside the program
Rule of grammar
type classname::varName = value;
Example
class test{
private:
static int t1;// Static member functions
};
int test::t1 = 0;// You also need to define
3、 ... and 、 Summary
- Class can be passed through static Keyword to define static member variables
- Static member variables belong to all classes
- Every object can access static member variables
- Static member variables allocate space in the global data area
- The lifetime of static member variables is the running time of the program
版权声明
本文为[Night rain]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231155356003.html
边栏推荐
- The fourth chapter is about enabling and disabling the im column storage of table space for im enabled filling objects (IM 4.5)
- Link sorting of tutorials such as assembly language running environment setting
- Redis learning 5 - high concurrency distributed lock practice
- ThinkPHP adds image text watermark to generate promotion poster with QR code
- Next.js 静态数据生成以及服务端渲染的方式
- Database design of forum system
- 一文详解头部位姿估计【收藏好文】
- IFLYTEK's revenue in 2021 was 18.3 billion yuan: a year-on-year increase of 41% and a net profit of 1.556 billion yuan
- c# 设置logo图标和快捷方式的图标
- 【Redis 系列】redis 学习十三,Redis 常问简单面试题
猜你喜欢
IDEA 代码格式化插件Save Actions
Metalama简介4.使用Fabric操作项目或命名空间
同态加密技术学习
Database design of simple voting system
Worder font page font comparison table
Share two practical shell scripts
How to expand the capacity of the server in the 100 million level traffic architecture? Well written!
The listing of saiweidian Technology Innovation Board broke: a decrease of 26% and the market value of the company was 4.4 billion
编程辅助工具推荐:图片工具snipaste
初探 Lambda Powertools TypeScript
随机推荐
The maximum number of remote desktop servers has been exceeded
ES6 learning notes II
Recommended programming AIDS: picture tool snipaste
IFLYTEK's revenue in 2021 was 18.3 billion yuan: a year-on-year increase of 41% and a net profit of 1.556 billion yuan
如果你是一个Golang面试官,你会问哪些问题?
Xinwangda announced that the price of battery products had been increased, and the investment of "weixiaoli" exceeded 1 billion
Database design of simple voting system
Here comes the detailed picture and text installation tutorial of H5 game
在 VSCode 中调试 Jest 的测试用例,VSCode调试Jest测试用例报错basedir=$(dirname “$(echo “$0“ | sed -e ‘s,\\,/,g‘)“)解决
第二十三课 临时对象
Im architecture: CPU architecture: SIMD vector processing (im-2.3)
IM表达式的目的(IM 5.2)
Fastjson 2 is coming, the performance continues to improve, and it can fight for another ten years
Nacos Foundation (9): Nacos configuration management from single architecture to microservices
Share two practical shell scripts
PSCP 基本使用
How imeu is associated with imcu (IM 5.5)
MySQL 的主从复制配置
科创人·派拉软件CEO谭翔:零信任本质是数字安全,To B也要深研用户心智
SOFA Weekly | 年度优秀 Committer 、本周 Contributor、本周 QA