Virtual functions in C + + (i) __jquery

Source: Internet
Author: User

Although it is difficult to find a C + + book or magazine that does not discuss polymorphism, most of these discussions make it difficult to use polymorphism and C + + virtual functions. In this article, I intend to make the reader understand the virtual function implementation technology in C + + from several aspects and combine some examples. To illustrate, write this article just want to exchange learning experience with you because I have a shallow knowledge, there are some mistakes and deficiencies, I hope everyone criticized and corrected, in this deep thank you.

I. Basic CONCEPTS

First, C + + realizes polymorphism through virtual functions. " Regardless of the class in which the message is sent, they send a message with the same form, and the handling of the message may change with the object of the takeover message "The way it is called polymorphism." "In the hierarchy of a class built on a base class, you can invoke a procedure of the same name in the object of any derived class, and the process provided by the invoked procedure can change with the class to which it belongs. The virtual function is first a member function that can be redefined in the derived class of the class and given another processing function.

Second, the definition of virtual function and the redefinition of 01 in the derived class. Class class Name {public:03. virtual member function description; 04.} 05.06. Class Name: base class Name {public:08. virtual member function description; 09.}

Three, the structure of virtual function in memory

1. Let's take a look at an example: 01.

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.