|
|
|
|
|
by kazinator
2675 days ago
|
|
> C++ is remarkably less safe than C C++ does add some unsafe features that don't exist in C. In C++, it is possible to convert a foo *
to a bar *
without a cast, and without a diagnostic, where foo and bar are different struct types. C doesn't permit this.Specifically, C++ allows this in the situation when foo is derived from bar by inheritance, a relationship that doesn't exist in C. Subsequently, pointer arithmetic is allowed on the converted pointer. the bar pointer can be displaced by 1. But the underlying array is of foo objects; it's the wrong size. |
|