Call sequence of base classes and subclasses (C #, Java)

zhaozj2021-02-16  64

Now that OO's programming ideas have become more and more accused, everyone is not very familiar with some basic things, such as the order of the base class and subclasses. Here I use C # to explain to everyone for a piece of code? Public class baseclass? {?? public string a = "baseclass"; ??????????????? public baseclass ) ?? {??????? ?? a = "initialization Baseclass"; ??} ???}? public class extendClass: baseclass? {?? private string b = "extendClass"; ?? public extendClass : base () ?? {??? b = "initialization extendClass";

??}

?} If we write code this? BaseClass A = New ExtendClass () program execution procedure to perform step 1. Private string b = "extendClass"; 2. Public string a = "baseclass"; 3. public baseclass () ?? {??????? ?? a = "initialization baseclass"; ??} 4.public extendClass (): base () ?? {? ?? b = "Initialization ExtendClass";

??} This is what I explained by c # as an example. Of course, the implementation process of other languages ​​may not be the same, as I know, Java execution process and C # are not only the same. His execution process is 1. Public string a = "baseclass"; 2. Private string b = "extendClass"; 3. public baseclass () ?? {??????? ?? a = "initialization baseclass"; ??} 4.public extendClass (): base () ?? {? ?? b = "Initialization ExtendClass";

??}

VB.NET is

1. Public string a = "baseclass"; 2. Public baseclass () ?? {??????? ?? a = "initialization Baseclass"; ??}

3. Private string b = "extendClass"; 4.public extendClass (): base () ?? {??? b = "Initialization ExtendClass";

??} Written here, do everyone a happy work.

转载请注明原文地址:https://www.9cbs.com/read-18305.html

New Post(0)