我有一個類實現了幾個抽象方法。當我繼承了該類我得到以下致命錯誤消息:錯誤:類必須聲明爲抽象或實現其餘方法
Class CI_Controller_Rest contains 6 abstract methods and must therefore be declared abstract or implement the remaining methods
與抽象方法的類:
class CI_Controller_Rest extends CI_Controller {
public function __construct() {
parent::__construct();
}
abstract public function index();
abstract public function get();
abstract public function head();
abstract public function post();
abstract public function put();
abstract public function delete();
}
,我延長CI_Controller_Rest
類:
class Welcome extends CI_Controller_Rest {
public function __construct()
{
parent::__construct();
}
public function index() {}
public function get() {}
public function head() {}
public function post() {}
public function put() {}
public function delete() {}
}
我應該怎麼做比這更多?
錯誤告訴你soution CI_Controller_Rest必須是一個抽象類!沒有太多要添加...你必須聲明該類(CI_Controller_Rest)爲抽象的,否則你必須提供該方法的實現... – obe6
@ obe6哦!我怎麼錯過了?我以爲我改變了CI_Controller_Rest來抽象。對! – Andrew