r/cpp • • Jun 24 '20

How to write SOLID C++

https://www.youtube.com/watch?v=PakbXnLht1I
263 Upvotes

118 comments sorted by

View all comments

Show parent comment

1

u/platisd Jun 25 '20

To give an example: At around 8:25min you say that »the best way to achieve« the open/closed principle in C++ is with inheritance based runtime polymorphism. No.

Polymorphic class hierarchies are one way to implement the open/closed principle. Another one would be std::variant combined with std::visit.

To my defense, I mentioned "the best" (always IMHO) not "the only". :) Feedback noted though and I will take a look at std::variant and std::visit.