Personally I find a range-based for loop much easier to understand and type than a regular for loop, especially if using iterators. An iterator for loop can be a major mess trying to type and read. Especially without using auto.
so a local object M is created from the D class object (a) which is used to initialize it, and the for loop iterates over the created object. the a object probably should have some values and the M class needs to be something that allows iteration, for all that to work.