The official term for "overriding" a non-virtual method

I am using the "simulate covariance by casting" method from this answer . But I want to mark Derived :: Clone with comments that make it clear that a method with the same signature and name exists in the base class. I wrote:

/*shadow*/ shared_ptr<Derived> Clone() const

      

But I'm not sure if the term "shadow" will be universally understood in this context. It appears to be more commonly used for local variables shadowing other local variables.

What's the official term for this kind of thing?

+3


source to share


3 answers


The standard (N4141) uses the term "hiding" for this, for example

Note. The names declared in V

and the left instance W

are hidden in B

, but the names declared in the right instance W

are not hidden at all. - end of note



10.2 / 11

However, shading is a widely used term for all sorts of name hiding, so it is perfectly fine to use it in a comment.

+3


source


The term "shading" is widely used to do this kind of scoping stuff.

Similar:



void foo(int x) {
   int x = 0; // << Shadows parameter x
}

      

Nothing "official" (I couldn't find the term used in the current standard draft document) but understood well enough IMO.

+2


source


I came across two terms used to describe this kind of behavior in a programming language, hiding and shading. I usually say that some function hides another function and that some variable obscures another variable.

by the way. There is an article on Wikipedia called Variable Shading .

I've also heard masking the name of the name, but not as often as hiding or shading.

+1


source







All Articles