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

边栏推荐
- Summary of deep learning tuning tricks
- Codeless June event 2022 codeless Explorer conference will be held soon; AI enhanced codeless tool launched
- [detailed explanation of Huawei machine test] check whether there is a digital combination that meets the conditions
- 用StopWatch 统计代码耗时
- Questions d'examen écrit classiques du pointeur
- Promise summary
- Selective parameters in MATLAB functions
- Pointer classic written test questions
- Self built DNS server, the client opens the web page slowly, the solution
- PDK工艺库安装-CSMC
猜你喜欢

F12 solve the problem that web pages cannot be copied

移植InfoNES到STM32

Notes, continuation, escape and other symbols

Configuration file converted from Excel to Lua

Vite configures the development environment and production environment
![[leetcode] 18. Sum of four numbers](/img/06/c160b47d756290e5474e4c07e68648.png)
[leetcode] 18. Sum of four numbers

剑指 Offer II 039. 直方图最大矩形面积

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

【torch】|torch. nn. utils. clip_ grad_ norm_

02. Develop data storage of blog project
随机推荐
Vite configures the development environment and production environment
[effective Objective-C] - memory management
First acquaintance with CDN
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
01. 开发博客项目之项目介绍
UCF (2022 summer team competition I)
Force buckle 1189 Maximum number of "balloons"
Unity Vector3. Use and calculation principle of reflect
Vulhub vulnerability recurrence 72_ uWSGI
剑指 Offer II 039. 直方图最大矩形面积
用StopWatch 统计代码耗时
Excel转换为Lua的配置文件
jdbc使用call调用存储过程报错
2022 half year summary
Unity gets the width and height of Sprite
How to download GB files from Google cloud hard disk
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
指針經典筆試題
28io stream, byte output stream writes multiple bytes
UCF(暑期团队赛二)