当前位置:网站首页>Class inheritance in yyds dry inventory C
Class inheritance in yyds dry inventory C
2022-07-06 04:49:00 【Andy ahui】
Welcome to be my reader , I hope this article can give you some help .
Preface
In daily program coding work , Our ultimate goal is to complete the development tasks assigned by the company , The core goal is to write good code .
So what is good code ?
High cohesion , Low coupling
We must be engaged in coding , I've almost heard this sentence . So what kind of code is highly cohesive , How about low coupling .
Today, let's learn about C# In this high-level language , Through those forms .
In current high-level languages , These three characteristics are common , It is also often used in our daily coding . Namely encapsulation 、 Inherit 、 polymorphic .
Let's first look at inheritance
Class inheritance
Through inheritance, we can get a new class , The new class can define a series of methods and variables by itself , It also has the properties and behaviors of the base class .
The relationship here is base class and derived class .
It should be noted that derived classes cannot delete any members of the base class .
The above example ,InfoBase It belongs to the base class ,Ahui It belongs to a derived class , You can see that inheritance is achieved by colons .
Inherited members can be accessed , Just as they are declared by the derived class itself .
Currently, all classes are derived from object class ,object Class is the only non derived class , It is the basis of inheritance hierarchy . Classes that currently have no base class specification are implicitly derived directly from classes object.
matters needing attention
1、 There can only be one separate class in the base class specification of a class declaration , It is called single inheritance .
2、 Although a class can only directly inherit one base class , But there is no limit to the level of inheritance .
At present, derived classes cannot delete members and functions of base classes , But you can shield base class members and functions by declaring the same members in derived classes . Note here that the names must be the same .

remarks
Life is short , I don't want to pursue what I can't see , I just want to catch what I can see .
Originality is not easy. , Pay attention .
I am a A Hui , Thank you for reading , If it helps you , Please like it 、 forward thank you .
I'm glad to be friends with you .
边栏推荐
猜你喜欢

IPv6 comprehensive experiment

SQL注入漏洞(MSSQL注入)

Ue5 small knowledge points to enable the setting of lumen

Introduction of several RS485 isolated communication schemes

Vulnerability discovery - vulnerability probe type utilization and repair of web applications

Redis - redis in action - redis actual combat - actual combat Chapter 1 - SMS login function based on redis - redis + token shared session application - with code

几种RS485隔离通讯的方案介绍

Visio draw fan

Zynq learning notes (3) - partial reconfiguration

Database - MySQL storage engine (deadlock)
随机推荐
Microservice resource address
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
Postman test report
Redis - redis in action - redis actual combat - actual combat Chapter 1 - SMS login function based on redis - redis + token shared session application - with code
RTP GB28181 文件测试工具
图论的扩展
也算是學習中的小總結
acwing周赛58
Dynamic programming (tree DP)
[Yu Yue education] reference materials of complex variable function and integral transformation of Northwestern Polytechnic University
Meet diverse needs: jetmade creates three one-stop development packages to help efficient development
[try to hack] John hash cracking tool
Postman断言
[HBZ sharing] how to locate slow queries in cloud database
yolov5 tensorrt加速
[detailed steps of FreeRTOS shift value for the first time]
MPLS experiment
Crazy God said redis notes
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
Weng Kai C language third week 3.1 punch in