Add some comments to the generated-C++ output

Add some comments to the generated-C++ output to make scanning of the code a bit easier: which for-loop is being closed, which alloc is going out of scope.