Abstract classes and Abstract Functions

Source: Internet
Author: User

Object-oriented applications (I)

Suffering from customers' changing demands"

According to customer requirements, printers of different brands have the functions of starting, shutting down, and printing, so the code will not be written here



1. Syntax features of Abstract Functions

What is an abstract function?

Only functions are defined. functions without function bodies are called abstract functions:

Absyract void fun ();


2. Syntax features of abstract classes


What is an abstract class?

Classes defined by abstract are called abstract classes;

1. abstract classes cannot generate objects;

2. If a class contains abstract functions, the class must be declared as an abstract class;

3. If there is no abstract function in a class, this class can also be declared as an abstract class.


3. Role of abstract classes


Abstract classes are born to be used as the father, and are born to be inherited. abstract classes cannot generate objects, but subclasses can


1. Abstract Functions are functions without function bodies.

2. abstract classes are defined using abstract

3. abstract classes cannot generate objects, but they can have constructors.

Abstract classes and Abstract Functions

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.