简体   繁体   中英

Inheritance in php with abstract methods

I try to inherit from an abstract class to an abstract class:

abstract class Android{
    public $description="unknown brand";
    public function __construct() {

    }
    public function get_description(){
        return $this->description;
    }    
    public abstract function cost();
}

abstract class FeaturesDecorator extends Android {
    public abstract function get_description();
}

I get this error:

Fatal error: Cannot make non abstract method Android::get_description() abstract in class FeaturesDecorator in C:\\xampp\\htdocs\\jPlugin\\DesignPatterns\\Decorator\\Decorator.php on line 65

why? what ruins the inheritance?

函数get_description已在您的父类中定义并声明,您不能在子代中使其抽象化。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM