当前位置:网站首页>第二十六课 类的静态成员函数
第二十六课 类的静态成员函数
2022-04-23 11:55:00 【꧁༺夜༒雨༻꧂】
第二十六课 类的静态成员函数
一、静态成员函数
特点
- 不依赖对象就可以访问静态成员变量
- 必须保证静态成员变量的安全性
- 方便快捷获取静态成员变量的值
- 静态成员函数是类中的特殊成员函数
- 静态成员函数属于整个类所有
- 可以通过类名直接访问公有的静态成员函数
- 可以通过对象访问公有静态函数成员
定义
static type function()
直接通过static关键字修饰成员函数
二、静态成员函数和普通成员函数
静态成员函数 | 普通成员函数 | |
---|---|---|
所有对象共享 | √ | √ |
隐含this指针 | × | √ |
访问普通成员变量(函数) | × | √ |
访问静态成员变量(函数) | √ | √ |
通过类名直接调用 | √ | × |
通过对象名直接调用 | √ | √ |
三、小结
- 静态成员函数是类中的特殊成员函数
- 静态成员函数没有隐藏的 this 指针
- 静态成员函数可以通过类名直接访问
- 静态成员函数只能直接访问静态成员变量(函数)
版权声明
本文为[꧁༺夜༒雨༻꧂]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_34355238/article/details/124360530
边栏推荐
- [web daily practice] eight color puzzle (float)
- Laravel绑定钉钉群警报(php)
- 魔域来了H5游戏详细图文架设教程
- 云呐|如何管理好公司的固定资产,固定资产管理怎么做
- 欣旺达宣布电池产品涨价 此前获“蔚小理”投资超10亿
- IDEA 代码格式化插件Save Actions
- 第四章 为物化视图启用和禁用IM列存储(IM 4.6)
- Use kettle to copy records to and get records from results
- The fourth chapter is about enabling and disabling the im column storage of table space for im enabled filling objects (IM 4.5)
- 5个免费音频素材网站,建议收藏
猜你喜欢
Force buckle - 70 climb stairs
欣旺达宣布电池产品涨价 此前获“蔚小理”投资超10亿
Resolution due to AMD not found_ ags_ x64. DLL, unable to continue code execution. Reinstallation of the program may solve this problem, Forza horizon 5
MQ在laravel中简单使用
Understanding of MQ
Siri gave the most embarrassing social death moment of the year
Next.js 静态数据生成以及服务端渲染的方式
如果你是一个Golang面试官,你会问哪些问题?
VMware虚拟机使用esxi 导出硬盘vmdk文件
MQ is easy to use in laravel
随机推荐
Nacos Foundation (6): Nacos configuration management model
Design and practice of the smallest short website system in the whole network
论文解读(CGC)《CGC: Contrastive Graph Clustering for Community Detection and Tracking》
论坛系统数据库设计
C# F23. Stringsimilarity Library: String repeatability, text similarity, anti plagiarism
2022 love analysis · panoramic report of industrial Internet manufacturers
Sigmoid function of activation function
Redis learning 5 - high concurrency distributed lock practice
Practical data Lake iceberg lesson 30 MySQL - > iceberg, time zone problems of different clients
科创人·派拉软件CEO谭翔:零信任本质是数字安全,To B也要深研用户心智
Resolution due to AMD not found_ ags_ x64. DLL, unable to continue code execution. Reinstallation of the program may solve this problem, Forza horizon 5
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
User interface and im expression (IM 5.6)
Nacos Foundation (8): login management
Chapter 5 optimizing queries using in memory expressions (IM 5.1)
Chapter 4: enable and disable im column storage for materialized view (IM 4.6)
第五章 使用In-Memory表达式优化查询(IM 5.1)
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 5.2)
Fabric 1.0 source code analysis (33) implementation of peer channel command and subcommand