Object-oriented Inheritance abstract interface

Source: Internet
Author: User

Subclasses inherit from the parent class, inheriting a class by adding a colon after the class
Once an inheritance relationship is formed, the object of the subclass can use the public properties and method functions in the parent class
Subclasses can be converted to a parent class, but the parent class is not necessarily able to turn into subclasses
The parent class object can be converted back only if the parent object is converted by a subclass object.
From which subclass, you can only go back to that subclass.
Objects that are built directly from the parent class's constructor and cannot be converted to child class objects
When a method with the same name as the parent class is overridden in a subclass,
By which class the object points out the method, corresponding to that class inside the method content

Overridden method, if you add virtual in the parent class to override the subclass,
When you convert from a subclass object to an object of the parent class type, the child class method is called through the parent class object

Abstract class: Class name classes preceded by abstract
Abstract classes cannot create objects (instances) and can only be used as parent classes in an inheritance relationship
Other usages have the same inheritance usage as ordinary classes

Abstract method:
Can only be written in abstract classes
The content of the method must be overridden by override in the subclass
If not, then the subclass becomes an abstract class by default.
You have to inherit it somewhere else.

Abstract properties, note that the attribute is not a field.
As with abstractions, you need to rewrite them.

Interface:
A class can inherit only one parent class, but a class may inherit multiple interfaces
Interface cannot create its own instance, the interface cannot write segments, attributes
The method in the interface cannot have the method content, must be in the subclass to implement,
Implementation of the interface by the name of the point out method to achieve

Object-oriented Inheritance abstract interface

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.