当前位置:网站首页>第二十六课 类的静态成员函数
第二十六课 类的静态成员函数
2022-04-23 11:55:00 【꧁༺夜༒雨༻꧂】
第二十六课 类的静态成员函数
一、静态成员函数
特点
- 不依赖对象就可以访问静态成员变量
- 必须保证静态成员变量的安全性
- 方便快捷获取静态成员变量的值
- 静态成员函数是类中的特殊成员函数
- 静态成员函数属于整个类所有
- 可以通过类名直接访问公有的静态成员函数
- 可以通过对象访问公有静态函数成员
定义
static type function()
直接通过static关键字修饰成员函数
二、静态成员函数和普通成员函数
静态成员函数 | 普通成员函数 | |
---|---|---|
所有对象共享 | √ | √ |
隐含this指针 | × | √ |
访问普通成员变量(函数) | × | √ |
访问静态成员变量(函数) | √ | √ |
通过类名直接调用 | √ | × |
通过对象名直接调用 | √ | √ |
三、小结
- 静态成员函数是类中的特殊成员函数
- 静态成员函数没有隐藏的 this 指针
- 静态成员函数可以通过类名直接访问
- 静态成员函数只能直接访问静态成员变量(函数)
版权声明
本文为[꧁༺夜༒雨༻꧂]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_34355238/article/details/124360530
边栏推荐
- The listing of saiweidian Technology Innovation Board broke: a decrease of 26% and the market value of the company was 4.4 billion
- The fourth chapter is to enable the filling object of IM and enable ADO for im column storage (IM 4.8)
- Chapter 5 optimizing queries using in memory expressions (IM 5.1)
- Database Navigator 使用默认MySQL连接提示:The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrecognized or repres
- TclError: no display name and no $DISPLAY environment variable
- C# F23.StringSimilarity库 字符串重复度、文本相似度、防抄袭
- 5个免费音频素材网站,建议收藏
- 如果你是一个Golang面试官,你会问哪些问题?
- oh-my-lotto
- IDEA 中 .properties文件的中文显示乱码问题的解决办法
猜你喜欢
Step function of activation function
一文详解头部位姿估计【收藏好文】
docker MySQL主从备份
Significance of actively participating in middle school robot competition
解决由于找不到amd_ags_x64.dll,无法继续执行代码。重新安装程序可能会解决此问题,地平线(Forza Horizon 5)
On the integration of steam education in early childhood education
VMware virtual machines export hard disk vmdk files using esxi
Understanding of MQ
Yunna | how to manage the company's fixed assets and how to manage fixed assets
NativeForMySQL 连接MySQL8 提示:1251- Client does not support authentication protocol
随机推荐
Understanding of MQ
博客文章导航(实时更新)
Tensorflow使用keras创建神经网络的方法
MQ的了解
IDEA 代码格式化插件Save Actions
Redis learning 5 - high concurrency distributed lock practice
Who said you should know PS? This open-source artifact can also be pulled in batch, and the effect is outstanding!
Force buckle - 70 climb stairs
Practical data Lake iceberg lesson 30 MySQL - > iceberg, time zone problems of different clients
2022 love analysis · panoramic report of industrial Internet manufacturers
Blog post navigation (real-time update)
Nacos Foundation (6): Nacos configuration management model
MySQL 的主从复制配置
IDEA 代码质量规范插件SonarLint
C# F23. Stringsimilarity Library: String repeatability, text similarity, anti plagiarism
Sofa weekly | excellent Committee of the year, contributor of this week, QA of this week
On the integration of steam education in early childhood education
Design and practice of the smallest short website system in the whole network
Next.js 静态数据生成以及服务端渲染的方式
Windows11 安装MySQL服务 提示:Install/Remove of the Service Denied