当前位置:网站首页>CSDN21天学习挑战赛——封装(06)
CSDN21天学习挑战赛——封装(06)
2022-08-11 07:03:00 【二哈喇子!】
活动地址:CSDN21天学习挑战赛
学习的最大理由是想摆脱平庸,早一天就多一份人生的精彩;迟一天就多一天平庸的困扰。各位小伙伴,如果您:
想系统/深入学习某技术知识点…
一个人摸索学习很难坚持,想组团高效学习…
想写博客但无从下手,急需写作干货注入能量…
热爱写作,愿意让自己成为更好的人…
…
封装
面向对象的三大特征:封装,继承,多态。
什么是封装? 隐藏实现细节,暴露出合适的访问方式。(合理隐藏、合理暴露)
**
封装的实现步骤
一般对成员变量使用private(私有)关键字修饰进行隐藏,private修饰后该成员变量就只能在当前类中访问。
提供public修饰的公开的getter、setter方法暴露其取值和赋值。
封装的好处小结
加强了程序代码的安全性。
适当的封装可以提升开发效率,同时可以让程序更容易理解与维护。
学习日记
1.封装是什么,一般封装怎么体现出来?
面向对象的三大特征之一,合理隐藏,合理暴露。
一般会把成员变量使用private隐藏起来。
通过getter和setter方法暴露其访问。
2.封装有什么好处?
加强了程序代码的安全性。
适当的封装可以提升开发效率,同时可以让程序更容易理解与维护
边栏推荐
- DDR4内存条电路设计
- 1002 Write the number (20 points)
- linux 安装mysql服务报错
- Conditional statements in TF; where()
- 1071 Small Gamble (15 points)
- leetcode:69. x 的平方根
- 2022-08-09 Group 4 Self-cultivation class study notes (every day)
- Implementation of FIR filter based on FPGA (5) - FPGA code implementation of parallel structure FIR filter
- Pico neo3在Unity中的交互操作
- 从苹果、SpaceX等高科技企业的产品发布会看企业产品战略和敏捷开发的关系
猜你喜欢
【Pytorch】nn.PixelShuffle
1046 punches (15 points)
The growth path of a 40W test engineer with an annual salary, which stage are you in?
恒源云-Pycharm远程训练避坑指南
Project 1 - PM2.5 Forecast
1002 Write the number (20 points)
【Pytorch】nn.ReLU(inplace=True)
【软件测试】(北京)字节跳动科技有限公司二面笔试题
1051 Multiplication of Complex Numbers (15 points)
Taobao product details API interface
随机推荐
1071 Small Gamble (15 points)
Dynamic Agent Learning
Pico neo3在Unity中的交互操作
Production and optimization of Unity game leaderboards
Pico neo3 Unity打包设置
3.2-分类-Logistic回归
【LeetCode每日一题】——844.比较含退格的字符串
Internet phone software or consolidation of attack must be "free" calls security clearance
Two state forms of Service
1106 2019数列 (15 分)
梅科尔工作室——BP神经网络
1076 Wifi密码 (15 分)
1003 我要通过 (20 分)
Write a resume like this, easy to get the interviewer
1091 N-自守数 (15 分)
CIKM 2022 AnalytiCup Competition: 联邦异质任务学习
oracle19c不支持实时同步参数,请教一下大佬们有什么好的解决办法吗?
查找最新人员工资和上上次人员工资的变动情况
oracle19c does not support real-time synchronization parameters, do you guys have any good solutions?
1101 How many times B is A (15 points)