How do you check if you are writing a new method or overriding it?

I mean, if I'm inside my class B, which extends some other class A (not created by me), how do you know that the method you write is:

void SetStatus() { }

it has not yet been announced, and you just redefine it? Right Click -> Go to Definition Each Time? (e.g. on VS2015).

+4
source share
2 answers

If you have code - you can declare a method finalin your base class, then the code will not compile if you try to override the virtual method.

If you want to override it, you can try calling A :: SetStatus (); in the definition of B :: SetStatus ().

IDE , A. " ", .

+1

( ++ 11), :

void SetStatus() override { }

, , . , , (.. SetStatus() ) ​​ , . , override specifier.

0

Source: https://habr.com/ru/post/1649548/


All Articles