Re-understanding of inheritance

Source: Internet
Author: User

when it comes to inheritance, my first reaction is: the non-technical example, the child inherits the father's performance ability, the child also has the extra music ability. Because of this first reaction, when I see: Comments inherit the news, it is a bit difficult to accept, why the comments inherit the news ah? The inheritance relationship should not be the same, like children inherit parents, birds inherit animals ( News category, such inheritance, the equivalent of birds inherit animals, but also easy to accept. ), how come a completely different thing, showing the inheritance relationship?


The beef brisket says "comments belong to a certain news, so comments inherit the news." Why
from the concept of inheritance, inheritance refers to the ability of a class (called a subclass, sub-interface) to inherit the functionality of another class (called the parent class, parent interface) and to increase its own new functionality.
comments Inherit news, sub-category comments belong to a piece of news, so, have all the properties of this news. Fully conforms to the concept of inheritance, subclasses have properties of the parent class.

From here, I understand the inheritance as belonging to the relationship. For example, a savings account and a checking account belong to a bank account; news belongs to a news category; a comment belongs to a news;


The previous understanding of inheritance has remained in some examples of image, and has not been implemented into the concept. But the concrete system, often does not have so the image, may combine the image the example first to understand, but finally must implement to the concept. After all, the example you remember is probably one-sided.


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Re-understanding of inheritance

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.