Hacker News new | ask | show | jobs
by 2716057 820 days ago
I'm wondering why the "final" keyword is not mentioned in the article.
2 comments

This is a good point. Using final and a static cast to the derived type should eliminate the indirect call.
What does "final" mean in C++? Is that new? Maybe you're confusing with java?
> Is that new?

No. In fact in a few short months post C++11 will have overtaken pre-C++11 as the majority of the 26 year history of standardized C++ (and similar to prior standards, compilers for the fortunate implemented much of the behavior prior to the official publication).

> post C++11 will have overtaken pre-C++11 as the majority of the 26 year history of standardized C++

that's because they switched to a different 'release cycle' for C++ standards, also now they have minor releases like C++14.

The release cycle does not change the number of years that have elapsed before and after 2011.
C++11 adds support for specifying "final" on derived virtual functions to prevent further overriding of the function by any derived classes of the current "final" class.
Yep. Imported more-or-less from Java OOP.
https://en.cppreference.com/w/cpp/language/final

Final in C++ indicates that the function/class can no longer be overridden in further child classes. This enables devirtualization as the compiler can then know the function pointer will not change, if it can infer the type at compile time.