Updated the destructor for the C++ example to correctly release memory.