The idea of oo programming has become more and more common,
However, some basic things are still vague,
For example, the call sequence of the base class and subclass.
Here I use c # as an example to show you how:
(The capability is limited. If you have any flaws, please kindly advise ^_^)
For the following code
Public class baseClass
{
Public string a = "baseClass ";
Public baseClass ()
{
A = "initialize baseClass ";
}
}
Public class ExtendClass: baseClass
{
Private string B = "ExtendClass ";
Public ExtendClass (): base ()
{
B = "initialize ExtendClass ";
}
}
If we write code like this
BaseClass a = new ExtendClass ()
Procedure
1. Private string B = "ExtendClass ";
2. Public string a = "baseClass ";
3. public baseClass ()
{
A = "initialize baseClass ";
}
4. public ExtendClass (): base ()
{
B = "initialize ExtendClass ";
}
This is explained in the example of c #. Of course, the execution processes of other languages may be different. As far as I know, java's execution process is not only the same as c.
In Java, this declaration method is called object transformation object declaration. Its execution process is as follows:
1. Public string a = "baseClass ";
2. Private string B = "ExtendClass ";
3. public baseClass ()
{
A = "initialize baseClass ";
}
4. public ExtendClass (): base ()
{
B = "initialize ExtendClass ";
}
Vb.net is
1. Public string a = "baseClass ";
2. Public baseClass ()
{
A = "initialize baseClass ";
}
3. private string B = "ExtendClass ";
4. public ExtendClass (): base ()
{
B = "initialize ExtendClass ";
}
Now, let's write it here and enjoy your work.
Learn from each other ~ Common progress ~
O (partition _ partition) o...