Answers for "C++ Vector Initialization method 02"

C++
0

C++ Vector Initialization method 02

#include <iostream>
#include <vector>
using namespace std;

int main() {
    
  // uniform initialization
  vector<int> vect{1, 2, 3, 4, 5};
  
  cout << "vector = ";

  // ranged loop
  for (const int& i : vect) {
    cout << i << "  ";
  }
  
  return 0;
}
Posted by: Guest on May-05-2022

Browse Popular Code Answers by Language