1, the introduction and creation of the interface
Keyword: interface
2, the interface Reference and specification
Keyword: implements
Interface: A special abstract class in which the member attributes are all abstract, and the function of the norm in the program
1. All the abstract methods in the class
2, abstract method before you do not add abstract
3. Interface Abstract Method property is public
4. The member property must be a constant
Abstract:
1. There is at least one abstract method in the class
2, abstract method before the need to add abstract
Common:
1, can not be instantiated by itself, must be inherited or referenced
2. After inheriting or referencing, all abstract methods need to be overloaded before they can be used
The interface has its own creation keyword: interface is similar to the creation of a normal class
Interface Demo {
Const name= "name";
function Fun1 ();//object methods are all abstract methods, the front does not need to add adstract
function Fun2 ();
}
The interface can use keywords: implements multiple references and separate them with commas.
1, common class reference interface example:
Class MyPC implements demo, Demo2, demo3{
......
}
2, abstract class Reference interface example:
Abstract class MyPC implements demo, Demo2, demo3{
......
}
3, inherit the parent class reference interface Coexistence Example:
Class MyPC extends Root implements demo, Demo2, demo3{
......
}
4. Interface and interface inheritance:
Interface Demo3 extends demo{
......
}
http://www.bkjia.com/PHPjc/486152.html www.bkjia.com true http://www.bkjia.com/PHPjc/486152.html techarticle 1, the introduction of the interface and the creation of keywords: interface 2, interface reference and canonical keyword: implements interface: A member property is all abstract special abstract class, in the program with ...