hachyderm.io is one of the many independent Mastodon servers you can use to participate in the fediverse.
Hachyderm is a safe space, LGBTQIA+ and BLM, primarily comprised of tech industry professionals world wide. Note that many non-user account types have restrictions - please see our About page.

Administered by:

Server stats:

9.5K
active users

Šimon Tóth

When working with virtual functions, we can encounter situations where we need to return a different type from an overriding function.

While this isn't possible in the general case, the types returned are allowed to be different if they are covariant (the overriding function returns a derived type).

The prototypical use for covariant return types is a clone() function.

Compiler Explorer link: compiler-explorer.com/z/qTxErs