当前位置:网站首页>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){ }
边栏推荐
- [C language] Dynamic Planning --- from entry to standing up
- Feature Engineering: summary of common feature transformation methods
- MySQL error: expression 1 of select list is not in group by claim and contains nonaggre
- Pytoch --- use pytoch to realize u-net semantic segmentation
- Thinkphp6 limit interface access frequency
- How much can a job hopping increase? Today, I saw the ceiling of job hopping.
- Actual combat | use composite material 3 in application
- Playing with concurrency: what are the ways of communication between threads?
- Learn AI safety monitoring project from zero [attach detailed code]
- Play with concurrency: what's the use of interruptedexception?
猜你喜欢
Its appearance makes competitors tremble. Interpretation of Sony vision-s 02 products
Alibaba cloud polkit pkexec local rights lifting vulnerability
The confusion I encountered when learning stm32
【c语言】动态规划---入门到起立
Microsoft Research Institute's new book "Fundamentals of data science", 479 Pages pdf
Unit testing classic three questions: what, why, and how?
Go language introduction
One step implementation of yolox helmet detection (combined with oak intelligent depth camera)
Yolov5网络修改教程(将backbone修改为EfficientNet、MobileNet3、RegNet等)
The core idea of performance optimization, dry goods sharing
随机推荐
Www2022 | know your way back: self training method of graph neural network under distribution and migration
Exposure X8 Standard Version picture post filter PS, LR and other software plug-ins
How to solve the problem that objects cannot be deleted in Editor Mode
蓝湖的安装及使用
Markdown编辑语法
Force buckle 540 A single element in an ordered array
Okcc why is cloud call center better than traditional call center?
阿里云polkit pkexec 本地提权漏洞
66.qt quick QML Custom Calendar component (supports vertical and horizontal screens)
Yyds dry inventory compiler and compiler tools
Installation and use of blue lake
C language practice - number guessing game
BGP experiment the next day
Go language naming specification
unable to execute xxx. SH: operation not permitted
How much can a job hopping increase? Today, I saw the ceiling of job hopping.
Go branch and loop
Actual combat | use composite material 3 in application
Pytorch-Yolov5从0运行Bug解决:
Lei Jun wrote a blog when he was a programmer. It's awesome