当前位置:网站首页>private封装
private封装
2022-08-05 02:42:00 【黑白不纯】
1. 封装就是将类中尽可能多的属性和方法隐藏其来,不让外部程序直接访问,而是通过提供的公共方法间接访问。
2、封装实现的步骤
1)使用private修饰属性和方法
2)提供公共的getXxx()/setXxx()方法
3)在getXxx()/setXxx()方法内对数据进行判断
3、类的访问权限修饰符有哪些及作用范围
public:共有访问级别,任何地方都可以访问
默认修饰符:包级私有,同一个包内可以访问
4、类成员的访问修饰符
public、protected、默认修饰符、private
边栏推荐
- 程序员的七夕浪漫时刻
- C student management system head to add a student node
- Advanced Numbers_Review_Chapter 1: Functions, Limits, Continuity
- C language diary 9 3 kinds of statements of if
- 627. 变更性别
- [深入研究4G/5G/6G专题-51]: URLLC-16-《3GPP URLLC相关协议、规范、技术原理深度解读》-11-高可靠性技术-2-链路自适应增强(根据无线链路状态动态选择高可靠性MCS)
- QStyle平台风格
- 常见的硬件延迟
- 多线程(2)
- shell statement to modify txt file or sh file
猜你喜欢
C language diary 9 3 kinds of statements of if
Simple implementation of YOLOv7 pre-training model deployment based on OpenVINO toolkit
Common hardware delays
海量服务实例动态化管理
Unleashing the engine of technological innovation, Intel joins hands with ecological partners to promote the vigorous development of smart retail
Optimizing the feed flow encountered obstacles, who helped Baidu break the "memory wall"?
dmp(dump)转储文件
J9数字货币论:web3的创作者经济是什么?
Access Characteristics of Constructor under Inheritance Relationship
【OpenCV 图像处理2】:OpenCV 基础知识
随机推荐
1667. 修复表中的名字
[Decryption] Can the NFTs created by OpenSea for free appear in my wallet without being chained?
Optimizing the feed flow encountered obstacles, who helped Baidu break the "memory wall"?
Access Characteristics of Constructor under Inheritance Relationship
The design idea of DMicro, the Go microservice development framework
1667. Fix names in tables
Compressed storage of special matrices
特殊矩阵的压缩存储
VSCode Change Default Terminal 如何修改vscode的默认terminal
Pisanix v0.2.0 发布|新增动态读写分离支持
nodeJs--封装路由
UOS系统下ksql应用缺少动态库”libtinfo.so.5“问题
开源协议说明LGPL
LeetCode使用最小花费爬楼梯----dp问题
软链接引发的物理备份问题
View handler 踩坑记录
dmp(dump)转储文件
虚拟内存原理与技术
Data storage practice based on left-order traversal
View handler stepping record