This article to share the content is about the Python object-oriented inheritance and polymorphism, has a certain reference value, the need for friends can refer to
In OOP programming, when we define a class, we can inherit from an existing class, the new class is called a subclass (subclass), and the inherited class is called the base class, the parent class, or the superclass (base classes, Supper Class).
For example, we have written a class named Animal
program. Therefore, it is a good choice to simply modify the class t to take charge of two responsibilities, although this is contrary to the single responsibility principle. (The risk lies in the uncertainty of responsibility diffusion, because we will not think of this responsibility P. In the future, it may spread to P1, P2, P3, P4 ...... Pn. Remember to refactor the code immediately before the responsibility spreads beyond our control .)
For example, a class is used to describe the
Principle(This abbreviation was proposed by Michael feathers ):
S: single Responsibility Principle
O: open and closed principles
L: Lee's replacement principle
I: interface isolation principle
D: Dependency inversion principle
Next we will discuss in detail.Note: most examples in this article may not meet the actual situation or can not be applied to actual applications. It depends entirely on your own design and scenarios. Most importantlyUnderstand and understand how to apply/follow th
ensure that the value of this variable is not modified, the final modifier is added. This is a constant with high readability. Writing specification. All the letters in the constant name modified by final are capitalized. If multiple words are connected. Iii. abstract classes and interfaces 1. abstract classes: when describing a thing, there is not enough information to describe a thing, then it is an abstract thing. Classes that define abstract functions must also be modified by abstract keywo
In OOP programming, when we define a class, we can inherit from an existing class, the new class is called a subclass (subclass), and the inherited class is called a base class, a parent class, or a superclass (base class, Super Class).
For example, we have written a class called Animal, and a run () method can be printed directly:
Class Animal (object):
def run (self):
print '
the corresponding output mode switching.
Now we're going to do it. C language Inheritance and polymorphism, we still take a more classic animal world examples to illustrate: Suppose the animals (including people) would eat (Eat), would go (Walk), would say (Talk), and the derived classes were dog (doggy) and Cat (cats), and of course could be more , dog and cat have their own unique eat, walk, and talk, and the approximate code is as follows:
Base
The previous blog introduced the encapsulation of javascript object-oriented programming principles. Today, we will introduce inheritance to you. There is no class concept in javascript, and it cannot be like c # or java, directly use classes to inherit classes. For example, there is an "animal" object constructor.
Function Animal (){
This. species = "animal ";
... ######################################## ### [100%]
1: mySQL-client ##################################### ###### [100%]
[Root @ host2 mysql_rpm] #
13
Connect to mysql and modify
[Root @ host2 mysql_rpm] # nl/root/. mysql_secret
1 # The random password set for the root user at Tue Jan 20 13:10:43 2015 (local time): F76Wy1A4G9ZuLcaG
[Root @ host2 mysql_rpm] # mysql-p mysql
Enter password:
Welcome to the MySQL monitor. Commands end with; or \ g.
Y
): two or more method function names of the same scope (generally referred to as a Class) are the same, and the parameter list differs by the method called overloading, they have three characteristics (commonly known as two must be one):
Method names must be the same
Parameter list must be different
Return value types can be different
Such as: public void Sleep () { Console.WriteLine ("Animal Sleeps");
The software versions used in this series are as follows:Windows 7 x64/windows Server X64Arcgis for Desktop 10.1Arcgis 10.1 for serverArcSDE10.1SQL ServerVS 2010The data used is all stored in the SDE.Arcgis server10.1(no permanent guarantee):Http://yun.baidu.com/s/1kTp96RlWhen installing, you need to set the user name password, here must remember clearly.Set account as ArcGIS password gis,123Next, you can export the account information into an XML The contents of the XML are stored as follows, a
): two or more method function names of the same scope (generally referred to as a Class) are the same, and the parameter list differs by the method called overloading, they have three characteristics (commonly known as two must be one):
Method names must be the same
Parameter list must be different
Return value types can be different
Such as: public void Sleep () { Console.WriteLine ("Animal Sleeps");
"Class" and "instance" in JavaScript, javascript instance
JavaScript does not have a parent class, a subclass, or a class or instance. prototype chain is used to implement inheritance. when you look for an object's properties, JavaScript will traverse the prototype chain up until the corresponding properties are found. there are several methods that allow JavaScript to simulate the concepts of class and instance.
1. Use the constructor directly to create an object. Use this within the constructo
Inheritance and polymorphism
In OOP programming, when we define a class, we can inherit from an existing class, and the new class is called a subclass (subclass), and the inherited class is called the base class, the parent class, or the superclass (base-Class, Super-Class).Write a class named Animal that has a run () method to print directly:>>> class Animal (object): Def run (self): print ('
In OOP programming, when we define a class, we can inherit from an existing class, and the new class is called a subclass (subclass), and the inherited class is called the base class, the parent class, or the superclass (base-Class, Super-Class).For example, we have written a class named Animal , and there is a run() way to print it directly:class Animal (object): def Run (self): Print ('
Because the implementation of "virtual" in C ++ requires the use of derivative means, while derivation is the generation type, the "virtual" is generally mapped to the indirect type, rather than the indirect implementation of the above channel through an instance (a set of common harmonic circuits. Note: The "simplified operation" refers to the complex operation of function ing, which simplifies code writing and indirectly executes the corresponding code using the address mapped by function nam
JAVA learning course 15th (polymorphism and its basic applications), java learning PolymorphismPolymorphism:The third feature of object-oriented definition: a function with the same name has multiple forms. For example, a function with a polymorphism has different parameter lists, and its existence is different, there is also a function that is placed in the parent class and in the subclass, and its existence is also different.The object also has polymorphism.Example: animals include pigs, cats,
operation" refers to the complex operation of function ing, which simplifies code writing and indirectly executes the corresponding code using the address mapped by function name, virtual functions are called to present multiple execution results. "Improving Efficiency" is an algorithm improvement, that is, the channel is achieved by repeating ten sets of common harmonic circuits, and the authentic space is changed for time, it is not indirectly implemented on the type. Therefore, the "virtual"
This article illustrates the class and instance implementation methods in JavaScript. Share to everyone for your reference. Specifically as follows:
JavaScript does not have a parent class, the concept of subclasses, there is no class and instance concept, rely on prototype chain to achieve inheritance. When you look up an object's properties, JavaScript traverses the prototype chain up until you find the corresponding property. There are several ways to enable JavaScript to simulate the concep
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.