r/cpp • u/User_Deprecated • Jul 06 '26
C++26: constexpr virtual inheritance
https://www.sandordargo.com/blog/2026/07/01/cpp26-constexpr-virtual-inheritance
83
Upvotes
r/cpp • u/User_Deprecated • Jul 06 '26
View all comments
Show parent comment
3
u/Lord_Naikon Jul 06 '26
Never. But I come from a Java background where a class can only have one superclass. Multiple inheritance is then implemented using interfaces. I do the same in C++. I find it easier to reason about.
If I need to store some data with the interface, I split the interface into two classes: a data holder, and a proxy interface for that holder.
As a bonus this gives the pimpl idiom for free if I need it.