The understanding of C + + virtual function

Source: Internet
Author: User

As for the process of inheriting classes, from an abstraction to a gradual materialization , the base class can be very, very abstract, and the derived classes that are finally instantiated are very specific.

The meaning of virtual functions is that it is possible to define a function from the earliest base class to the final derived class (which can be either re-implemented or not re-implemented depending on the requirements, but pure virtual functions must be implemented, for reasons that I have already said in other articles) .

This feature constantly changes depending on the needs of the derived class as the derived class continues to inherit the base class. When we call virtual functions of different derived classes, we can have different functions. And then someone said, it's not as bad as every derived class has to rename a function on its own, in theory, absolutely, in a project where the parent class and its inherited classes are not many, it's perfectly possible to do so, as long as you can memorize it yourself or find the renaming function, but in a larger project, Because of the hundreds of functions in the class, I'm afraid you're going to freak out.

The understanding of C + + 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.