When a class is defined to implement an interface, the class must provide definitions of all the methods defined in the interface. Otherwise, you will get compiler time error.
A class must implement all methods of the interface, unless the class is declared as abstract. There are only two choices:
- Implement every method defined by the interface.
- Declare the class as an abstract class, as a result, forces you to subclass the class (and implement the missing methods) before you can create any objects.
interface bird{
function color();
function weight();
}
class Bird_class implements bird{
function color(){
echo "Color is blue";
}
function weight(){
echo "Weight is 40grms";
}
}
0 comments:
Post a Comment