当前位置:网站首页>C - derived classes and constructors
C - derived classes and constructors
2022-07-02 04:30:00 【Tsim Sha Tsui duankun 415】
Subclass object , When there is a part, the base class part , Before executing the constructor of the subclass , The parent constructor will be called implicitly or explicitly
using System;
class MyDerived : MyBase
{
int field1 = 1;// First of all , Instance member initialization
MyDerived() { }// Third , Subclass constructor
// There will be an implicit call , When calling displayed MyDerived():base()
}
class MyBase
{
public MyBase(){}// second , Parent constructor
}Call other constructors of the current class
Use this, It means to call the current class , Like this name Constructors , There may be many names that need to be overloaded , At this time, you only need to create one in the current class , This avoids creating too much duplicate code
This is called calling a public initialized function
Pet(int age, string name):this(name){ }
Pet(string name){ }
边栏推荐
- Federal learning: dividing non IID samples according to Dirichlet distribution
- Yyds dry goods inventory kubernetes introduction foundation pod concept and related operations
- unable to execute xxx. SH: operation not permitted
- Exposure X8 Standard Version picture post filter PS, LR and other software plug-ins
- Arbre binaire pour résoudre le problème (2)
- Research on the security of ognl and El expressions and memory horse
- 如何解决在editor模式下 无法删除物体的问题
- ThinkPHP kernel work order system source code commercial open source version multi user + multi customer service + SMS + email notification
- powershell_ View PowerShell function source code (environment variable / alias) / take function as parameter
- Li Kou interview question 02.08 Loop detection
猜你喜欢

Realizing deep learning framework from zero -- Introduction to neural network

One step implementation of yolox helmet detection (combined with oak intelligent depth camera)

Alibaba cloud polkit pkexec local rights lifting vulnerability

缓存一致性解决方案——改数据时如何保证缓存和数据库中数据的一致性

Common sense of cloud server security settings

What is 5g industrial wireless gateway? What functions can 5g industrial wireless gateway achieve?

The confusion I encountered when learning stm32

Mysql表insert中文变?号的问题解决办法

Learn what definitelytyped is through the typescript development environment of SAP ui5

Play with concurrency: what's the use of interruptedexception?
随机推荐
Target free or target specific: a simple and effective zero sample position detection comparative learning method
Today's plan: February 15, 2022
C language guessing numbers game
unable to execute xxx. SH: operation not permitted
文档声明与字符编码
okcc为什么云呼叫中心比传统呼叫中心更好?
第十六周作业
Wechat applet map annotation
深圳打造全球“鸿蒙欧拉之城”将加快培育生态,优秀项目最高资助 1000 万元
Yolov5网络修改教程(将backbone修改为EfficientNet、MobileNet3、RegNet等)
How to model noise data? Hong Kong Baptist University's latest review paper on "label noise representation learning" comprehensively expounds the data, objective function and optimization strategy of
Ognl和EL表达式以及内存马的安全研究
Let正版短信测压开源源码
PIP installation of third-party libraries
C language practice - number guessing game
Websites that it people often visit
汇编语言中的标志位:CF、PF、AF、ZF、SF、TF、IF、DF、OF
BGP experiment the next day
Cache consistency solution - how to ensure the consistency between the cache and the data in the database when changing data
Installation et utilisation du lac bleu