📜  c++ foreach - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:45.835000             🧑  作者: Mango

代码示例1
// C++ program to demonstrate use of foreach
#include 
using namespace std;
  
int main()
{
    int arr[] = { 10, 20, 30, 40 };
  
    // Printing elements of an array using
    // foreach loop
    for (int x : arr)
        cout << x << endl;
}

//output:
//10
//20
//30
//40