Small collection of minimal C++ programs that demonstrate common memory errors:
buffer_overflow.cpp– writing past the end of an arraynull_pointer.cpp– dereferencing a null pointeruse_after_free.cpp– accessing memory after it has been freeddangling_pointer.cpp– returning address of a local variable
These examples are intentionally unsafe.