r/cpp • • 26d ago

How I design C++ classes

https://rafb.eu/blog/cpp-class-design/

This is my first ever blog-post, any feedback is welcome! ofc, no AI got used.

66 Upvotes

46 comments sorted by

View all comments

Show parent comment

1

u/decapod2005 22d ago

final keyword only helps when you are not actually doing polymorphism. As long as you access the impl function through the base class interface, the compiler can do nothing.

Measuring is important to find bottlenecks, but they become buch harder to find when your first, default approach is already pessimized. When every functionality has to go through hundreds of virtual function calls, you won't see any improvement if you optimize one of them.

It's not a good idea to by default add abstractions that you do not need.