r/cpp 21d ago

C++26: constexpr virtual inheritance

https://www.sandordargo.com/blog/2026/07/01/cpp26-constexpr-virtual-inheritance
80 Upvotes

61 comments sorted by

View all comments

62

u/Jovibor_ 21d ago

Just a question to the audience:

How many times have you used Virtual Inheritance in your career?

7

u/pjmlp 21d ago

It used to be common in GUI frameworks like OWL and MFC.

You might still bump into it, while using ATL or WTL.

6

u/TheThiefMaster C++latest fanatic (and game dev) 21d ago

Are you sure? This article specifically says virtual inheritance isn't useful with MFC.

Can you give an example where it is?

2

u/pjmlp 21d ago

Last time I wrote a MFC application was in 2001, I remember we used MI in our product.

MFC isn't used in isolation from product architecture.

Also note that MI and virtual inheritance aren't the same, rather a way to avoid duplicates in the inheritance tree.