Malou Gade
1
Q:

references in c++

#include <bits/stdc++.h>  
using namespace std;  
  
int main()  
{  
    vector<int> vect{ 10, 20, 30, 40 };  
  
    // We can modify elements if we  
    // use reference 
    for (int &x : vect)  
        x = x + 5; 
  
    // Printing elements 
    for (int x : vect)  
       cout << x << " ";  
  
    return 0;  
}  
0

New to Communities?

Join the community