Overload and Override

xiaoxiao2021-03-06  74

This is two very easily confused concepts, they have the same important position in C . 1.OverLoad Overload: Generally used for functions to form overload function. Such as: void A (int inumber) {cout << inumber;} Void A (FLOAT FNUMBER) {cout << FNumber;} Overloaded an important concept is different, the compiler determines the function that needs to be coupled according to the parameter table . This way we can implement different functions through a calling method. Especially in terms of constructor and operators.

2.Override rewrite: I like Mr. Jie, although it feels uncomfortable, but clearly expresses its difference from overload, such as Class A {public: A (); ~ a (); virtual void output () {cout << "class a"};

Class B: Public a {public: b (); ~ b (); Virtual void output () {cout << "class b"};}; very obvious, this is a virtual function of derived class. Override can help us complete the polymorphism of the class. However, a little bit of OverLoad is the same in his function original (including parameter table).

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

New Post(0)