Introduction to C + + Classic-Example 8.9-abstract class, pure virtual function, creating pure virtual function

Source: Internet
Author: User

1: A class containing a pure virtual function is called an abstract class, and an abstract class has at least one pure virtual function. An abstract class can only be derived as a new subclass of a base class, not in a program (that is, an object that cannot describe an abstract class), but with pointers to abstract classes. Not all code is written by the software Architect during program development, and sometimes it is necessary to call library functions and sometimes write to others. A software architect can establish an interface through a pure virtual function, and then let the programmer fill in the code to implement the interface, and is primarily responsible for creating abstract classes.

2: pure virtual function

A pure virtual function is a virtual member function that is marked as not specifically implemented, and it does not have function functions. In many cases, you cannot give a meaningful definition of a virtual function in a base class, and you can declare it as a pure virtual function in the base class, and the implementation is left to the derived class. Pure virtual functions cannot be called directly, but only provide an interface that is known to the derived class.

Declares a pure virtual function in the form of:

Introduction to C + + Classic-Example 8.9-abstract class, pure virtual function, creating pure virtual function

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.