书中原句是“在循环体外定义迭代变量只对那些支持含有一个逗号的数据类型的容器类才适用”
原版的句子是 "Defining the iteration variable outside the loop is the only option for containers
that hold data types that contain a comma”
所以我的理解是 含有一个逗号的数据类型的容器类只能在循环体外定义迭代变量
书中的句子会让人觉得 不含逗号数据类型的容器类就不能在循环体外定义迭代变量了
而且foreach的帮助文档里也有这么一句:Unless the data type contains a comma (e.g., QPair<int, int>), the variable used for iteration can be defined within the foreach statement
以上是我的一些看法