当前位置:网站首页>[Tang Laoshi] C -- encapsulation: classes and objects
[Tang Laoshi] C -- encapsulation: classes and objects
2022-07-06 05:34:00 【Tang laoshiyi】
Through the last article , We have basically understood the basic concepts of object-oriented programming : Everything is object , Use program code to describe each object , Use object-oriented thinking to write programs . So today we'll look at how to describe objects in a program .
【 Classes and objects 】
【 What is a class? ?】
Having the same characteristics
Have the same behavior
The abstraction of a class of things
Class is a template for an object
You can create objects through classes
Keywords of class
class
Classes are generally written in namespace In the block
These are all called classes
human beings
Machine class
Plants
Now these classes have not been used to specifically describe and describe their contents , We will learn later . What you need to remember is , If you want to describe an object , that 90% Will use class keyword , You're sure to ask about the rest 10% Well ?
You remember struct Structure ? It is a data aggregation , It is the rest 10%! Specific and class The difference between , We'll talk about it later .
【 What is an object ?】
Objects are created by classes
Class to create objects
Commonly referred to as instantiated objects
Instantiate object keywords
new
Class is just a template for us to describe a class of things , In general , We don't use classes directly to do anything . We will instantiate the class as an object , Use objects to do some logical operations .
You can think of it this way , There are thousands of people , We need several people to instantiate several objects to use , Just like Nu Wa pinching a clay figurine . All objects are under our control !
【 summary 】
Class is a template for an object
Used to abstract real objects
Object is an instance of a class
Used to represent a real object individual
Class is a custom variable
Instantiate class objects
Is declaring variables
Focus on Tang Laoshi Get more dry content
边栏推荐
- Text classification still stays at Bert? The dual contrast learning framework is too strong
- 改善Jpopup以实现动态控制disable
- Select knowledge points of structure
- 移植InfoNES到STM32
- LeetCode_ String inversion_ Simple_ 557. Reverse word III in string
- How to get list length
- 27io stream, byte output stream, OutputStream writes data to file
- nacos-高可用seata之TC搭建(02)
- HAC集群修改管理员用户密码
- Figure database ongdb release v-1.0.3
猜你喜欢
Safe mode on Windows
自建DNS服务器,客户端打开网页慢,解决办法
图数据库ONgDB Release v-1.0.3
Using stopwatch to count code time
Fluent implements a loadingbutton with loading animation
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
JS array list actual use summary
flutter 实现一个有加载动画的按钮(loadingButton)
【经验】win11上安装visio
How to download GB files from Google cloud hard disk
随机推荐
Qt TCP 分包粘包的解决方法
Jvxetable implant j-popup with slot
[untitled]
Summary of redis basic knowledge points
[QNX Hypervisor 2.2用户手册]6.3.3 使用共享内存(shmem)虚拟设备
UCF (2022 summer team competition I)
Web Security (V) what is a session? Why do I need a session?
Huawei od computer test question 2
Mongodb basic knowledge summary
指针经典笔试题
Mysql高级篇学习总结9:创建索引、删除索引、降序索引、隐藏索引
Please wait while Jenkins is getting ready to work
LeetCode_ String inversion_ Simple_ 557. Reverse word III in string
Talking about the type and function of lens filter
Graduation design game mall
Vulhub vulnerability recurrence 73_ Webmin
趋势前沿 | 达摩院语音 AI 最新技术大全
Vulhub vulnerability recurrence 69_ Tiki Wiki
Jvxetable用slot植入j-popup
C# AES对字符串进行加密