Appendix: Fast forward to reality
This is the age of modern C++. Visual Studio 2022, and other wonders. Also, now there is this MSVC “permissive” compiler switch, and there was this upheaval and debate around it. And the most feverish ones in that debate have been the same ones who abused the inheritance in them dark ages of C++. And to top it up.
They have been using templates but in the wrong way.
And they have appeared “clever” too. So what exactly is the problem they now have with modern C++? It is the introduction of a so-called “Two-phase name lookup“. Another very good explanation/solution is here. Please do not glance over; do visit those two links.
Just an important note from me on the permissive MSVC compiler switch. If I may.
You can use the /permissive- , cl.exe compiler switch to ask for standards-conforming compiler behaviour.
As simple as that. This is not a switch for the conformance to a particular C++ version. It is simply here to warn you if you are breaking modern C++ rules. Remove that hyphen and you can sort-of-a break them.
The little quiz for fun and profit
The followers of the 1990-ies mass religion of inheritance, now need to change their code to conform to modern C++ compilers.
Just because in their youthful and fast past, they used the “clever” (template) inheritance. Ditto: every base class or call, now has to be changed to make it conform to modern C++ compilers. Please consider this extremely simple code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
template<typename T> struct Base { T x{}; T f() { return x; } }; // inheritance struct Derived : Base<int> { int age() { return f(); } }; // class Aggregated { Base<int> age{ 42 }; public: int g() { return age.f(); } }; |
Please focus as I do have the following questions:
- Why is a class Derived a “better design” vs Aggregated class?
- Why is a class Derived more resilient to change vs Aggregated?
- Derived knows about Base member x. Is that good or bad?
And so on. I am sure I could add lots more questions here.
For the conclusion here is one of Mr Stroustrup’s slides:

Yes, Bjarne has nailed it.