Definition, which is equivalent to a specification. an abstract class cannot be instantiated. it can only be instantiated after being overloaded in a derived class. Abstract class: when at least one method in a class is an abstract method, it can be called an abstract class. abstract functions must be added before abstract methods and abstract classes. More importantly, they can be used as a standard and a ruler. If no abstract class is overloaded in the derived class, an error is returned.
Definition, which is equivalent to a specification. an abstract class cannot be instantiated. it can only be instantiated after being overloaded in a derived class.
Abstract class. an abstract class can be called only when at least one method in a class is an abstract method. abstract methods and abstract classes must be added before abstract methods.
It is used as a standard and a ruler. If no abstract class is overloaded in the derived class, an error is returned.
- Abstract class Cxclass {
- Abstract function Name ();
- Abstract function Stroe ();
- Abstract function Sex ();
- }
- Class Myclass extends Cxclass {
- Public $ name;
- Public $ stroe;
- Public $ sex;
- Function _ construct ($ name, $ stroe, $ sex ){
- $ This-> name = $ name;
- $ This-> stroe = $ stroe;
- $ This-> sex = $ sex;
- }
- Function Name (){
- Return "name". $ this-> name ."
";
- }
- Function Stroe (){
- Return "score". $ this-> stroe ."
";
- }
- Function Sex (){
- Return "gender". $ this-> sex ."
";
- }
- }
- $ Myclass = new Myclass ("small", 96, "male ");
- Echo $ myclass-> Name (). $ myclass-> Stroe (). $ myclass-> Sex ();
- ?>
Output result
Small name
Score 96
Gender Male