15-02-2017, 01:18 PM
Hi,
I don't think that 5-2-3 covers the given situation:
As I have already written: using reinterpret_cast is probably silly since there are better ways to do. But it is possible and someone might actually have a good reason for using it.
The aim of my question is rather general, are derived classes "related" or "unrelated"? Therefore, does rule 5-2-7 apply if you do any pointer conversion (where reinterpret_cast is the most rough one)?
I don't think that 5-2-3 covers the given situation:
- 5-2-3 is handling only downcasts whereas my question is about both directions (i.e. casting from a dervied to its base class, too)
- 5-2-3 is only about polymorphic types, yet not everything which is inherited is necessarily polymorphic: in my example, the classes don't have any virtual functions, or think about private inheritance.
- 5-2-3 is labeled "advisory", which means that I can assume a project situation where 5-2-3 is not active but 5-2-7 is.
As I have already written: using reinterpret_cast is probably silly since there are better ways to do. But it is possible and someone might actually have a good reason for using it.
The aim of my question is rather general, are derived classes "related" or "unrelated"? Therefore, does rule 5-2-7 apply if you do any pointer conversion (where reinterpret_cast is the most rough one)?
<t></t>