I once asked a question about how to design a piece of C++ code (which can be found here C++ - Good or bad practice?) and people told me that down-casting is considered a bad practice except for very specific scenarios.
However, I've seen many pieces of code in C# and Java where it seems to be a totally natural way of doing things. For example in Android SDK, you have the function Activity#findViewById()
that returns a View that you then down cast to its actual class:
TextView tv = (TextView) this.findViewById( R.id.myTextView );
Why would this need to be avoided in C++ and not in other languages ?
I know that C# and Java both support introspection natively, and not C++ which would require on kind of type field, but in the end it's the same thing, isn't it ?