Added c++ code showing foreach loop