| 
 | 
 
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
int arr[3][4] = { {1,2,3,4},{2,3,4,5},{3,4,5,6} }; 
 
for (const  int  row[4]: arr) {       //这行不知道为什么不能用arr初始化 const int row[4] 
        for (int i : row) cout << i << endl; 
}
这样的代码对吗? 
- #include <iostream>
 
  
- int main() {
 
 -     int a[3] = {1, 2, 3};
 
 -     int b[3] = a;
 
 -     return 0;
 
 - }
 
 
  复制代码 
不对吧,应该是这样吧?
 - #include <iostream>
 
  
- int main() {
 
 -     int a[3] = {1, 2, 3};
 
 -     int (&b)[3] = a;
 
 -     return 0;
 
 - }
 
 
  复制代码 
所以
 - #include <iostream>
 
  
- int main() {
 
 -     int array[3][4] = {{1, 2, 3, 4}, {2, 3, 4, 5}, {5, 6, 7, 8}};
 
 -     for(int (&row)[4]: array) {
 
 -     }
 
 -     return 0;
 
 - }
 
 
  复制代码 
 
 
 |   
 
 
 
 |