Class Student extends Person {Public $ name;Public $ age;Public function _ construct ($ name = "", $ age = 25 ){Parent: :__ construct ($ name, $ age );$ This-> age = $ age;}Public function say (){Parent: say ();Echo ", this year". $ this-> age. "years old ";}}?>
Next, let's look at an instance.
PHP5 rewrite MethodSet a parent class, which is a "Dog" class. This class describes the features of dog.
Dog has two eyes. It can run and be called. In this case, describe first.
I keep
() {Console.log (' Quack '); } };varChicken = {ducksinging:function() {Console.log (' Quack '); } };varChoir = [];//Choir varJoinchoir =function(animal) {if(Animal typeofanimal.ducksinging = = =' function ') {Choir.push (animal); Console.log (' Congratulations to join the choir '); Console.log (' Choir already has a membership number: '+ choir.length); } }; Joinchoir (duck);//Congratulations to join the choirJoinchoir (chicken);//Congratulations to join the choirWe see that for the choir-joined
Here, you think of yourself as God.1. ObjectsYou want to show your friends a graph, if you create a rotating square, a circle, and a triangle, he wants to see which graph you will show him which graph, is object-oriented;If you create a deformed shape, he will look at the internal series of judgments (because the graphics are many, so the inside will be very complex, and will affect each other) into what he wants to see is the process-oriented.2. What is the difference between a class and an obj
other ornaments on it (continue to expand).
/*base.js*/
module.exports = function () {
this.dosomething = function () {
console.log ("Nice to meet U.");
}
}
/*decorator.js*/
var util = require ("util)";
var Base = require ('./base ');
function decorator () {
base.call (this);
this.dosomething = function () {
base.dosomething ();
Console.log (' I am a decorator ');/expand Content
}
}
util.inherits (decorator, Base);//inheritance
module.exports = Decorat
Turn from: http://cloud.csdn.net/a/20120228/312507.html
It is well known that open source operating systems (such as UNIX and Linux) have achieved great success. One important reason for the popularity of Linux may be that its distribution can meet different audiences.
Today we're going to introduce you to five free lightweight Linux distributions.
Damn Small Linux
Official website: http://www.damnsmalllinux.org/
Damn Small Linux is a 50MB Linux distribution, but not less: a complete desktop en
}); $ (". Food"). CSS ({width:boxwidth,height:boxheight}); $ ("#box"). CSS ({width:boxwidth*3,height:boxheight*3,top: ( height-3*boxwidth)/2}); $ ("#score"). css ({LEFT:BOXWIDTH/3,TOP:BOXHEIGHT/3});Is the width of the screen one-eighth as each unit (single dog, food, and shells are also show love) of the wide height, and then the touch control function, control the movement of the puppy, when the click the puppy
=NewCat (); -Cat. Name ="Fish"; the Cat. Show (); - //Output Results//Kittens like to eat: Fish - - Console.readkey (); + - } + } A}So far there is no problem, but now you add: Puppy Eat fresh bone, kitten eat fresh fish, what will you do?Modify the method to the following form?Console.WriteLine ("Puppy likes to eat Fresh:" +name)Console.WriteLine ("Kitten likes to eat Fresh:" +na
Inheritance:Reuse code, avoid duplication, rewrite methods, new methods, and improve efficiency!3. Object classIs the ancestor of all classes, and any class inherits directly or indirectly from the object!.If a class does not show extends any class, the default inherits the object Class!4. Example: function: Aniaml class, Dog class, Cat class/**animal class*/Public classAnimalextendsobject{//ColorString color; //Age intAge ; Public voideat () {System.out.println ("Food for the Animals"); }
(local variables)
Instance variable
class, static variable
first, Local Variables (local variables)
Local variables are declared in a method, constructor, or block
Local variables are created when a method, constructor, or block is entered, and once you exit the variable it will be Destroyed.
An accessible descriptor cannot be used on a local variable
Local variables are visible only in declared methods, constructors, or blocks
Local variables are implement
disturb people to rest. It is absolutely forbidden." Many other words are hard to hear. Although I do not have the right to accuse these people, I have the freedom to comment. I want to use the Internet to let these people know my thoughts.
Some people always blame everything in the world, but do these people think that their behavior may not be like a dog in many places? Are there any bad places for dogs, is it true that all dogs have advantages? I don't think anyone can say that,
For exam
;attack ($z 1); // Suppose the object of a puppy is attacked $z1?>Functions with the same name can be used in different classes, such as the puppy's class zergling, which can also have a function attackNote that starting with PHP5, you can change the properties of an object no matter where it is changed. For example, the above a puppy object is passed as a parameter to the attack function of the machine gun
Original article links: http://blog.csdn.net/u011421608/article/details/30750355
1. Introduction
First, let's talk about the reference. You can remember that the reference is an alias. For example, Mr. Wang has a nickname called puppy. His mother calls the puppy to go home for dinner, that is, he calls Mr. Wang to go home for dinner.
Next we will use two lines of code to declare a reference (let's take Xia
parent type, such as animal bird = new bird ();
But the class line for the subclass at runtime
Any subclass can be replaced by a parent class.
Package com. day08.doutai. demo1; public abstract class Animal {private String name; private String gender;/*** meal Method */public abstract void eat (); public String getName () {return name ;} public void setName (String name) {this. name = name;} public String getGender () {return gender;} public void setGender (String gender) {this. gender = gender
domain, those who do not seek the world, and those who do not seek the moment. In the template mode, a piece of code is a subclass of the parent class instantiation and the result is a subclass. People Xiaohong = new Xiaohong (); People xiaofang = new xiaofang (); However, if there are more people, it is impossible for us to declare so many categories, which reflects the grasp of the concept of hierarchy. The view of Tranquility is of great help to our study and life. Therefore, we need to g
tasks within the time limit. You love to gossip and make excuses as efficient as you used to be. In short, you have created your own poor performance evaluation.
So what happened? Well, it's simple-you forgot the basics. if you're re looking for a way to get back into gear, revisit the advice you got when you were first starting out in the professional world, and follow these easy (but often ignored) bits of advice.
What's wrong with you? Very simple-you forgot the most basic things. If you are
construction device(3) through static factory assembly(4) Assembly by Example Factory(5) Assembly of the array(6) Assembly of the generic set (List,dictionary)(7) Assembly of generic objects(8) Assembly of events4.4.1.1 Assembly by AttributesIn this section, we illustrate, by way of example, how to assemble objects through attributes, we only discuss simple properties, such as arrays, collections, custom classes, which we put together in a later discussion, and this is the usual person and dog
1, class, like is responsible for the specific project of the supervisor, to the supervisor to do this matter, the supervisor can let his men to complete their own work, the final synthesis of the results to the supervisor to pass out, that is to complete the task. classDog ():"""simulation of puppy testing""" def __init__(self,name,age):"""Initialize all variables to be used"""Self.name=name Self.age= Agedefsit (self):"""let the
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.