C++ Overriding… overwriting?

后端 未结 5 1567
情深已故
情深已故 2020-12-14 19:51

I know what overriding is in C++. But, is there overwriting? If so, what does it mean?

Thanks.

5条回答
  •  一向
    一向 (楼主)
    2020-12-14 20:16

    Override is "the normal thing" in OOP: A derived class provides a different (i.e. more specialized) implementation for something, overriding the base class, e.g. apple::foo() overrides fruit::foo() if apple is a class derived from fruit. (not to be mistaken with overload by using different parameter signatures, which leads to completely distinct functions).

    Overwrite I know as to completely replace with another-definition. Not on a specific level but in general for the remainder of the programm. This sometimes gets used javascript, if a big framework has some special issues, and you don't want to tear the big file apart:

    
    

    However: I don't know of any such thing in C++, as a concurring redefinition of a function would always lead to errors already at compile time. At most, I can imaginge bending function pointers, or (re)defining call back hooks.

提交回复
热议问题