当前位置:网站首页>第二十六课 类的静态成员函数
第二十六课 类的静态成员函数
2022-04-23 11:55:00 【꧁༺夜༒雨༻꧂】
第二十六课 类的静态成员函数
一、静态成员函数
特点
- 不依赖对象就可以访问静态成员变量
- 必须保证静态成员变量的安全性
- 方便快捷获取静态成员变量的值
- 静态成员函数是类中的特殊成员函数
- 静态成员函数属于整个类所有
- 可以通过类名直接访问公有的静态成员函数
- 可以通过对象访问公有静态函数成员
定义
static type function()
直接通过static关键字修饰成员函数
二、静态成员函数和普通成员函数
| 静态成员函数 | 普通成员函数 | |
|---|---|---|
| 所有对象共享 | √ | √ |
| 隐含this指针 | × | √ |
| 访问普通成员变量(函数) | × | √ |
| 访问静态成员变量(函数) | √ | √ |
| 通过类名直接调用 | √ | × |
| 通过对象名直接调用 | √ | √ |
三、小结
- 静态成员函数是类中的特殊成员函数
- 静态成员函数没有隐藏的 this 指针
- 静态成员函数可以通过类名直接访问
- 静态成员函数只能直接访问静态成员变量(函数)
版权声明
本文为[꧁༺夜༒雨༻꧂]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_34355238/article/details/124360530
边栏推荐
- Fabric 1.0源代码分析(33) Peer #peer channel命令及子命令实现
- golang之筆試題&面試題01
- 2022 love analysis · panoramic report of industrial Internet manufacturers
- 零钱兑换II——【LeetCode】
- Tensorflow uses keras to create neural networks
- Blog post navigation (real-time update)
- [Web 每日一练] 八色拼图(float)
- 远程访问家里的树莓派(上)
- oh-my-lotto
- C# F23.StringSimilarity库 字符串重复度、文本相似度、防抄袭
猜你喜欢

《通用数据保护条例》(GDPR)系列解读三:欧洲子公司如何向国内母公司回传数据?

Siri gave the most embarrassing social death moment of the year

Understanding of MQ
![Change exchange II - [leetcode]](/img/ad/33b13a004208d613c9a211fec9e5b1.png)
Change exchange II - [leetcode]

Redis学习之五---高并发分布式锁实战

Exploring the equipment and teaching of robot education

全网最细的短网址系统设计与实战

解读2022机器人教育产业分析报告

解析幼儿教育中steam教育的融合

Share two practical shell scripts
随机推荐
Nacos Foundation (9): Nacos configuration management from single architecture to microservices
IMEU如何与IMCU相关联(IM 5.5)
激活函数之relu函数
Golang Pen & interview 01
欣旺达宣布电池产品涨价 此前获“蔚小理”投资超10亿
Interpretation 3 of gdpr series: how do European subsidiaries return data to domestic parent companies?
Chapter 4 specifies the attribute of the inmemory column on the no inmemory table for im enabled filling objects: examples (Part IV of im-4.4)
第四章 为IM 启用填充对象之启用和禁用表空间的IM列存储(IM 4.5)
Windows11 安装MySQL服务 提示:Install/Remove of the Service Denied
Exploring the equipment and teaching of robot education
Chapter 4 is a tutorial on forced filling of in memory objects with IM enabled filling objects (IM 4.7)
Step function of activation function
Overall plan management mode in maker Education
Cognition and R & D technology of micro robot
Tclerror: no display name and no $display environment variable
Interpretation of biological recognition in robot programming course
云呐|固定资产盘点中,支持多种盘点方式(资产清查盘点)
1.Electron开发环境搭建
Compress the curl library into a sending string of utf8 and send it with curl library
ES6 learning notes II