For compatibility reasons, C arrays degrade pointers. Type B[10] can degrade to B* , and inheritance means that assigning a pointer to B variable of type A* permissible.
Then you increment the value of this pointer, which adds size A to its address.
However, your assumption that pointer increment is a valid operation if the pointer does not point to an array of pointer type elements is incorrect.
If you try to combine the C ++ parts that are there, so it behaves like C with the more strongly typed OO functions, the looser input in the C parts affects the stronger typing in the C ++ parts. Itβs best to keep them separate, or at least document the expected behavior.
source share