当前位置:网站首页>[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

边栏推荐
- Qt TCP 分包粘包的解决方法
- Ora-01779: the column corresponding to the non key value saving table cannot be modified
- Pickle and savez_ Compressed compressed volume comparison
- js Array 列表 实战使用总结
- 28io stream, byte output stream writes multiple bytes
- CUDA11.1在线安装
- UCF(2022暑期团队赛一)
- 改善Jpopup以实现动态控制disable
- Summary of redis basic knowledge points
- Deep learning -yolov5 introduction to actual combat click data set training
猜你喜欢

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

Graduation design game mall

【云原生】3.1 Kubernetes平台安装KubeSpher

用StopWatch 统计代码耗时

Huawei equipment is configured with OSPF and BFD linkage

Configuration file converted from Excel to Lua

Nacos - TC Construction of High available seata (02)

Text classification still stays at Bert? The dual contrast learning framework is too strong

01. 开发博客项目之项目介绍

Modbus protocol communication exception
随机推荐
Quantitative description of ANC noise reduction
Easy to understand I2C protocol
Game push image / table /cv/nlp, multi-threaded start
LeetCode_ String inversion_ Simple_ 557. Reverse word III in string
Tetris
改善Jpopup以实现动态控制disable
应用安全系列之三十七:日志注入
Vulhub vulnerability recurrence 68_ ThinkPHP
Three methods of Oracle two table Association update
Easy to understand IIC protocol explanation
Promotion hung up! The leader said it wasn't my poor skills
[machine learning notes] univariate linear regression principle, formula and code implementation
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
Codeforces Round #804 (Div. 2) Editorial(A-B)
Pix2pix: image to image conversion using conditional countermeasure networks
PDK工艺库安装-CSMC
【云原生】3.1 Kubernetes平台安装KubeSpher
Modbus协议通信异常
Deep learning -yolov5 introduction to actual combat click data set training
Using stopwatch to count code time