Virtual understanding

zhaozj2021-02-16  64

About Virtual understanding

After the C course study, I feel that this concept is very difficult to understand; after the N-year C development experience, the power after the combination of Virtual and the function is started, and the height of understanding is: "The base class can call subclasses in the subclass. The base class is declared as a function of Virtual ", without Virtual, we can't do this. This understanding is not wrong, but if there is no in-depth understanding, you can only say "oo? Is Encapsulation, Inheritance, Polymorphism" is useless but useless ... Many examples of using Virtual, including and message mapping functions Combination. There may be many MFC beginners don't carefully consider a simple and interesting question, and the onok () function and the Virtual relationship of CDialog are the following posts. When the interview is asked to use the Virtual modified base class, that is, Class Cderive CBASE {....};, I have to answer, I don't know, pain! When I came back, I immediately found in MSDN, I finally understood, hehe. In the future post ready to translate the article about Virtual base class, if you are using .NET's friends, you can enter Virtual Bases Classes in the help index, Overview read English original. Differentiation and cooperation of overloading and redefine, this is the future post; the important position of Virtual in design mode. In the "design mode: can be used for object-oriented software", the method of introducing the class and object portfolio, Virtual's use plays a crucial role in it.

转载请注明原文地址:https://www.9cbs.com/read-19896.html

New Post(0)