virtual function Analysis of C + +

Source: Internet
Author: User

1. Virtual function (impure virtual)

  C + + virtual function is mainly to provide "runtime polymorphism", the parent class provides the default implementation of virtual functions, subclasses can be overridden by virtual functions.

2. Purely virtual functions (pure virtual)

C + + pure virtual functions are also "run-time polymorphic", the parent class cannot provide the implementation of the function, the subclass provides the implementation of the function. Classes that contain pure virtual functions, called "abstract classes", cannot be used with the new

To implement an object, only subclasses of the virtual function can implement the new.

3. Common function (no-virtual)

The normal function is statically compiled and is a mandatory implementation provided by the parent class to the child class.

virtual function Analysis of C + +

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.