当前位置:网站首页>第二十六课 类的静态成员函数
第二十六课 类的静态成员函数
2022-04-23 11:55:00 【꧁༺夜༒雨༻꧂】
第二十六课 类的静态成员函数
一、静态成员函数
特点
- 不依赖对象就可以访问静态成员变量
- 必须保证静态成员变量的安全性
- 方便快捷获取静态成员变量的值
- 静态成员函数是类中的特殊成员函数
- 静态成员函数属于整个类所有
- 可以通过类名直接访问公有的静态成员函数
- 可以通过对象访问公有静态函数成员
定义
static type function()
直接通过static关键字修饰成员函数
二、静态成员函数和普通成员函数
| 静态成员函数 | 普通成员函数 | |
|---|---|---|
| 所有对象共享 | √ | √ |
| 隐含this指针 | × | √ |
| 访问普通成员变量(函数) | × | √ |
| 访问静态成员变量(函数) | √ | √ |
| 通过类名直接调用 | √ | × |
| 通过对象名直接调用 | √ | √ |
三、小结
- 静态成员函数是类中的特殊成员函数
- 静态成员函数没有隐藏的 this 指针
- 静态成员函数可以通过类名直接访问
- 静态成员函数只能直接访问静态成员变量(函数)
版权声明
本文为[꧁༺夜༒雨༻꧂]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_34355238/article/details/124360530
边栏推荐
- 用户接口和IM表达式(IM 5.6)
- 力扣-1137.第N个泰波那契数
- 怎么进行固定资产盘点,资产盘点报告如何一键生成
- PCB的注意事项
- Maker education for primary and middle school students to learn in happiness
- User interface and im expression (IM 5.6)
- Master slave replication configuration of MySQL
- Exploring the equipment and teaching of robot education
- Precautions for PCB
- ES6学习笔记二
猜你喜欢

Redis learning 5 - high concurrency distributed lock practice

积极参与中学机器人竞赛的意义

Understanding of MQ

Interpretation 3 of gdpr series: how do European subsidiaries return data to domestic parent companies?

激活函数之sigmoid函数

Sofa weekly | excellent Committee of the year, contributor of this week, QA of this week

Sigmoid function of activation function

云呐|固定资产盘点中,支持多种盘点方式(资产清查盘点)
![抓包整理————tcp 协议[八]](/img/ae/4957a997af725a1bf3f61cb24fc717.png)
抓包整理————tcp 协议[八]

Nacos Foundation (8): login management
随机推荐
Nacos Basics (5): getting started with Nacos configuration
TclError: no display name and no $DISPLAY environment variable
项目实训-火爆辣椒
Redis学习之五---高并发分布式锁实战
《通用数据保护条例》(GDPR)系列解读三:欧洲子公司如何向国内母公司回传数据?
解决由于找不到amd_ags_x64.dll,无法继续执行代码。重新安装程序可能会解决此问题,地平线(Forza Horizon 5)
Laravel增加自定义助手函数
rebbitMQ的简单搭建
Understanding of MQ
Golang Pen & interview 01
IDEA 中 .properties文件的中文显示乱码问题的解决办法
力扣-1137.第N个泰波那契数
论坛系统数据库设计
Compress the curl library into a sending string of utf8 and send it with curl library
How the database fills in IM expressions (IM 5.4)
AcWing 1874. Moo encryption (enumeration, hash)
PCB的注意事项
配电房远程综合监控系统在10kV预制舱项目中的应用
Cognition and R & D technology of micro robot
Simple construction of rebbitmq