Answer the question
In order to leave comments, you need to log in
How to inherit?
Guys, why does inheritance fail? I study.
Here is my simple book class
$obj = new Book();
$post = array('name' => 'Книга1', 'author_id' => 10, 'price' => 1000);
$obj->create($post); //создаем книгу
$post = array('id' => 100, 'name' => 'Книга11', 'author_id' => 11, 'price' => 1111);
$obj->edit($post); //редактируем
$obj->delete($id); //удаляем
$obj->showAll(); //получаем весь массив книг
$obj->showOne(100); //получаем только одну книгу
Answer the question
In order to leave comments, you need to log in
Methods are not inherited, all parent methods are available to the class that inherits it.
In your case, I would simply extend the functionality of the Book class, since the work is related to it.
If you had a "Printed Products" class, then most of the methods would be there, and the classes Book, Newspaper, etc.
inherited from him. In these classes, there would be an implementation of only what applies to them, for example, a book has an author, but a newspaper does not ... something like this
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question