Objective
Students who have used python to write object-oriented code may be familiar with __init__ methods that ,__init__ run immediately when an object in a class is created. This method can be used to do some of the initialization you want for your object.
Note: This name starts and ends with a double underline.
Parent
/** * 人 * * @author LGL * */class Person { String name; int age;}
This person is called the parent class, super class, base class
And then our workers and students can write it like this.
/** * 学生 * * @author LGL * */
Abstract classes: Classes with abstract methods that need to be decorated with the abstractions keywordRelationship DiagramThe code belowPackage com.ray.testobject;/** * Abstract class * * @author Ray * @since 2015-05-02 * @version 1.0 * */public abstract class person {public abstract void getdescription ();}Package com.ray.testobject;/** * Implementation
The __init__ of the python3.6 child class calls the __init__ of the parent classParent classclass Worker: def __init__ (self): self.a=1 self.b=2if__name__= ="__main__ ": worker ()Sub-class fromtest.test02ImportworkerclassWorkertet (worker):def __init__(self): worker.__init__(self) C= 3D= 4Print(SELF.A)Print(self.b)Print(c)Print(d)defTest (se
(I am a newbie, new C ++) In general, the base class and the derived class (that is, the parent class and subclass) both contain Constructors (called when the class is created) and destructor (called when a class is deleted ).
Wh
development, avoid defining a field with the same name as the parent class in the child class. Don't ask for trouble!Appendix: Some code and explanations that are extracted on the Web can help understand.Example 1:public class A {protected String A = "1";Public String Geta
PHPCMS2008 the solution of inheriting the parent class of the sub-class of permission
In PHPCMS2008, each column can be assigned to different roles of different permissions, is based on the column as the starting point, and our general situation from the role of the starting point is not right, so it does not go to achieve the function of the column permissions
Recently I have a little experience in assigning a subclass object to a parent object, and I'd like to share it with you. But I have a limited level, please correct me and criticize you.To go to the point, here are a few small examples, please take a look. Test A Parent class:
public class Sup
1, the Mytank class inherits the tank, then the public part of Mytank inside is the common member and the method in Mytank can call and assignment, and do not have the new member variable in Mytank and the public member name in the tank, this will occur the call disorder, such as:Tank Tank = new Mytank ();int c = TANK.A;If public a= 3 is in the tank class, and the new definition public A = 2 in the Mytank s
The parent class application points to a subclass object and refers:
The parent class animal, subclass cat, dog. Here, animal can be an interface or class, and cat and dog are subclasses that inherit or implement animal.
Animal animal = new CAT ();
The declared
Detailed explanation of the heavy load parent class in the php object-oriented subclass. This article will explain how to overload the parent class in the php object-oriented Subclass. I hope this article will help you understand how to overload the parent
Suppose there is a parent class father, And the variables in it need to occupy 1 MB of memory. There is a sub-class son, and the variables in it need to occupy MB of memory.
Now we can use the code to check the memory allocation:
Father F = new father (); // The system will allocate 1 MB of memory.
Son S = new son (
This article will explain how to overload the parent class in the php object-oriented subclass. I hope this article will help you understand how to overload the parent class in the php subclass.
Because there cannot be a function with the same name in PHP, the method with the same name cannot be defined in the same
not.A parent loader object is wrapped in a child loader object.For example, Loader1 and Loader2 are instances of the Myclassloader class, and Loader2 wraps Loader1,loader1 as the parent loader for Loader2.When a custom ClassLoader instance is generated, the system ClassLoader becomes the parent loader for the ClassLoa
This interesting question that I stumbled upon.
Observe the following code, which has a String name variable defined in both the parent class and the subclass, and whether the final inheritance is left with 1 name only or the name of the parent subclass subclass is irrelevant.
By assigning a value, what the final outpu
recompiling the source code, but the result of the anti-compilation is as follows, There is no special place to explain the reason.Finally, check out Microsoft's MSDN official documentation to find the answer (original address click here)According to the official Microsoft code example, the following code has the same effect//Constructors for subclasses Genev
Copy Code code as follows:
Class Parent {
static variables
public static String P_staticfield = "Parent class-static variable";
Variables (in fact, this is better for objects with this, such as writing a
attributes are in the parent class, what attributes are in the subclass, and how many classes are to be created?
This is a task that needs to be completed for Object-Oriented Analysis and Design. The primary purpose of the parent class is to share code among multiple child
We often use inheritance in our projects, but we often don't quite understand the sequence and principle of the program running, especially when using the transition object, and when there are static variables and methods in the parent subclass, you don't know who to run first. I have also written an example. summed up a bit.
Copy Code code as follows:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.