Object-Oriented inheritance

Source: Internet
Author: User

MySQL class inherit class Stu extends human

1,. With one class as the parent class and another class as a subclass, the subclass inherits the property methods inside the parent class.

2. Code reuse and brevity

3. There can only be one parent class

4, public and protected can inherit, and have access and modify the permissions

5, private things can inherit but can not use or access

6. If you want to invoke a private property inside a parent class, you should use the Parent:: Method or property

7. After inheriting the parent class, the permission can only be more and more relaxed, not more strict.

If the Cry method permission for the parent class is inherited by the public subclass, it is wrong to change to protected.

8, the construction method will also be inherited __construct () can also be modified

9, but after rewriting causes initialization work cannot complete, how to do? : When subclass inherits, subclass has constructor, insure a little call parent::__construct ();

10, inherited property methods: The parent class has subclasses, there are subclasses of the parent class can be overridden, the parent class does not have subclasses can add

Object-Oriented 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.