This is an object of its own, representing the object itself, which can be understood as: A pointer to the object itself.The usage of this can be broadly divided into 3 types in Java:1. Normal Direct referencesThis does not have to be said, this is equivalent to pointing to the current object itself.2. The name of the member who participates in the membership is distinguished by this:Class Person { private int: age = ten; Public person () { System.out.println ("Initialization Age:" +ag
Ext: 52205961The Python language has similar class inheritance to C + +, in which Python customizes the first self, like the this pointer in C + +, to the object itself.Examples of simple Python classes:[Python]View PlainCopy
>>> class Hello (object):
... def print_c ():
...print"Hello world!"
>>> hello (). Print_c ()
Hello world!
Of course, in practice, the inevitable need for class inheritance, subclasses inherit the parent class, normal as follows:[Python]View
The Python language has similar class inheritance to C + +, and in the class definition, Python customizes the first self, similar to the this pointer in C + +, pointing to the object itself.
Examples of Python simple classes:
>>> class Hello (object):
... Def print_c ():
. print "Hello world!"
>>> hello (). Print_c ()
Hello world!
Of course, in practice, the inevitable need for class inheritance, subclass inherits the parent class, normal as follows:
>>> class Child (Hell
Jane's going to talk Super VLAN-conserving IP address isolation two layer communication VLAN aggregation in the implementation of the different Sub-vlan to share a subnet segment address, but also brought Sub-vlan between the three-layer forwarding problem. Want to do the DHCP server must do in the Super-vlan up[Huawei]vlan Batch 2 to 4 100[Huawei]vlan 100[Huawei-vlan100]aggregate-vlan//Configure the curren
Some people may think that why is there a super function in Python that can directly call the parent class method through the parent class name? In fact, many people have misunderstandings about the super function in Python, this article introduces the correct understanding and usage of the super function in Python programming. when the subclass needs to call the
This article mainly introduces the differences between super () and _ init _ () in the python class. This article is very detailed and has some reference value, you can refer to the functions implemented by super () and _ init _ () when inheriting a ticket.
class Base(object):def __init__(self):print 'Base create'class childA(Base):def __init__(self):print 'creat A ',Base.__init__(self)class childB(Base):
Look at the code:@implementation son:father-(ID) init{ = [Super init]; if (self) { } return to self ;}What is self and what is super ?In dynamic methods : Self stands for "object"; In static methods : Self stands for "class"; One sentence summary is: Selfrepresents the caller of the current method;Self and super are the two reserved words provided by
These days to see the class in the inheritance will use this and super, here do a little summary, with you to communicate, there are errors please correct me ~This This is an object of its own, representing the object itself, which can be understood as: A pointer to the object itself.The usage of this can be broadly divided into 3 types in Java:1. Normal Direct referencesThis does not have to be said, this is equivalent to pointing to the current obj
These days to see the class in the inheritance will use this and super, here do a little summary, with you to communicate, there are errors please correct me ~ThisThis is an object of its own, representing the object itself, which can be understood as: A pointer to the object itself.The usage of this can be broadly divided into 3 types in Java:1. Normal Direct referencesThis does not have to be said, this is equivalent to pointing to the current obje
refer to the online information and self-understanding summarize the respective usage and differences of this and super in Java The constructor is an important way to create a Java object, and when the constructor is called with the New keyword, the constructor returns the object for that class, but the opponent is not entirely created by the constructor. Creating an object is divided into the following four steps:A. Allocating object space and initi
The super function is used to solve diamond inheritance.First, the inheritance of Python and the invocation of the parent class memberParent class:class Base (object): def __init__ (self): print ("base init". ")Normal method calls the parent class:class Leaf (Base): def __init__ (self): base.__init__ (self) print ("Leaf init. ")The Super method calls the parent class:class Leaf (B
Java Object-oriented-–super keywords
1: Define father (parent Class) class
1: member variable int x=1;2: Construction method without parameter and argument, with output statement
2: Define son class extends Father class
1: member variable int y=1;2: The construction method is non-parametric and has a parameter. have output statement this.y=y+x;
3: Create son class object
Son son=new Son(3); Sy
Like what
class Child (Parent): def __init__ (self): Parent . __init__ (self)
Reply content:For your question, the answer is yes, and there is no difference. But I don't feel good enough to answer the question.
To talk about super, first we should ignore the interference of the name "Super".
don't talk about super when you think of the parent
outercls.innercls ();
}
}
Class outercls{
public static Class innercls{
Innercls () {
System.out.println ("Innercls");
}
}
}
The output will be as you expect.
Innercls
Same as the ordinary class. For other uses of internal classes, refer to the relevant chapters in the "I" Java, which are not detailed here.
Second, this super
In the previous section, we discussed the various uses of static, by defining a method or member with static,
Intel has recently been exerting its power at the channel end, and the computer stores, 3C stores and the manufacturers of the manufacturers have been pushing the pole. However, in the face of "super extreme" this jerky vocabulary, a large number of users do not understand their meaning. Many consumers think "ultra-extreme" means super lightweight and super perfo
To begin our question:@implementation son:father-(ID) init{self = [super init]; if (self) { } return to self;}This code estimates a lot of people write rotten, even if not write rotten, Xcode automatically generated we also see vomit. Well, to speak of the original,Come on: This is actually the INIT implementation of calling the parent class before the subclass implements initialization.It's not the same as saying, it's a blur.Fi
First look at the definition of the super () function:
super([type [,object-or-type]])
Return a **proxy object** This delegates method calls to a **parent or sibling** class of type.
Returns a proxy object that is responsible for assigning a method call to a parent or sibling class of the first parameter to complete.
How is the parent or sibling class determined?
The __mro__ property of the first param
When the subclass needs to call the method of the parent class, before python2.2, call the class's method directly with the class name, that is, the non-binding class method, and the self of the object is passed in the argument.
Class A (object): def Say (self): print ' I am A ' class B (a): def Say (self): print ' I am B ' A.say ( Self) B = B () B.say ()
Output
I am BI am A
This works fine, but there is a problem, when the parent class changed the name, it is necessary to
Think of Python's super () function, pythonsuper
Python-super
Thought of by the super () function of Python
First, let's take a look.super()Function Definition:
super([type [,object-or-type]])Return a **proxy object** that delegates method calls to a **parent or sibling** class of type.
ReturnsProxy objectThis object
wrong, hehe.Third, in the function, it is necessary to refer to the current object of the class that the letter belongs to, directly with this. In fact, these usage summary is from the "This is a pointer to the object itself" this sentence of a deeper understanding of the word, rote or easy to forget and easy to make mistakes, to understand! second, Super Super key is similar to this, is a masked member va
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.