[Compiler]Enable Run-Time Type Information

This solution is something you want to show to your students and tell them to never ever use it in their code. There are better solutions both: clean-code-wise and performance-wise:

It was probably Ok to use enum solution in some language in 1972 when there simply was no alternatives in your language back then. It is not Ok to use it in modern languages: in C++ case it’s since the moment it was introduced in 1979.

This one has all the problems the first one has. Instead of a switch statement you have a bunch of if statements everywhere your code uses this hierarchy.

2 Likes