Viturl abstract override

Source: Internet
Author: User

Object initialization sequence
Properties or fields of the derived class -----> properties or fields of the base class -----> constructors of the derived class 

A variable first and then Constructor
B is first static and then instantiated
C first base class and then derived class Constructor

C # understanding of viturl abstract override

The virtual identity method allows the derived class to override this method. The base class method already has the method body implementation, and the derived class adopts the override to identify and override this method;
Abstract identity allows a derived class to override this method. There is no method body implementation in the base class method, and override is used in the derived class to identify it. To override this method, the abstract method can only be included in the abstract class;
The override method allows the derived class to override this method. The base class method is to override the method of its parent class. The derived class uses override to identify and override this method;
The derived class method is identified by "new". The derived class method hides the method of the base class;

 

/* Differences between overload, overwrite, and hide
*
Overload is used for member functions in the same class. This behavior is called polymorphism and has the following features:
* 1) in the same class
* 2) Same Function Name
* 3) Different parameters (including different parameter types, different numbers, or different values). Note: it is irrelevant to the return value)
* 4) it has nothing to do with whether it is a virtual function.
Override refers to the function of a derived class that overrides a base class function. Its features are as follows:
* 1) different scopes (located in the derived class and the base class respectively)
* 2) Same Function Name
* 3) Same Parameters
* 4) The base function must be a virtual function.
Hidden (hide) refers to the function of a derived class that shields the base class functions with the same name. Its features are as follows:
* 1) different scopes (located in the derived class and the base class respectively)
* 2) Same Function Name
(3) If the parameters are different, the base class function does not have the virtual keyword, and the base class function will be hidden. (Because the derived class and the base class are not in the same range, they are hidden rather than overloaded );
() If the parameters are different, the base class function has the virtual keyword. The base function will be hidden. (Because the derived class and the base class are not in the same range, they are hidden rather than overloaded; because the parameters are different, they are hidden rather than overwritten );
() If the parameters are the same, the basic functions do not have the virtual keyword. The base function will be hidden. (Because the base-class functions are not virtual functions, they are hidden rather than overwritten ).
() If the parameters are the same, the base class function has the virtual keyword. If the base class function has multiple overloaded versions and the derived class does not override all virtual functions with the same name, when the function is called in the derived class, hidden virtual functions that are not overwritten in the base class. (Of course, The rewritten function is overwritten ).

* Note: To Call hidden functions in the base class in a derived class, you can enter the following in the derived class:Code: Using base: fun2

 

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.