top | item 44322112

(no title)

coderjames | 8 months ago

> most classes are not designed to be inherited but want to expose a clean public API.

> While true that all classes can be inherited

That's what the 'final' keyword in C++ is for: https://en.cppreference.com/w/cpp/language/final.html

"Specifies that a virtual function cannot be overridden in a derived class, or that a class cannot be derived from."

discuss

order

WorldMaker|8 months ago

C# and Java both have `sealed` for that, too.

throwaway2037|8 months ago

Nitpick: It is called "final" in Java, but your point stands. As I understand, C++ borrowed their "final" keyword from Java/C#. I'm not trolling when I write that last sentence. That is something that has really changed about C+ since the C++-11 committee was started -- and continues. When people write language / library proposals, they now regularly survey the landscape and talk about their experiences with other languages / libraries.