It is said that programmers should prefer composition over inheritance.
I was wondering if RTTI can be achieved as easily using composition.
1
It is possible to create an inspection mechanism that allows you to identify delegation. In general this is not desirable because it breaks encapsulation and thus limits your options to change the class under inspection without breaking client code. On the other hand, if you need that kind of information in a special case e.g. some application of the command or strategy pattern, it is easily possible to add your own reflection methods.
However, I cannot think of an example where I would not consider such an approach as a design flaw and I would encourage you to look for an alternative design in which the caller does not need to know about the inner workings of the called object.
1