Answers for "initialize a vector with values c++"

C++
4

c++ initialize a vector

#include <bits/stdc++.h> 
#include <vector> 
using namespace std; 
  
int main() 
{ 
// This vector initializes with the values: 10, 20, and 30
  vector<int> vect{ 10, 20, 30 }; 

    return 0; 
}
Posted by: Guest on April-26-2020
0

vector with initial value

// For declaring 
vector v(size, default_value);

// For Vector with a specific default value
// here 5 is the size of the vector
// and  10 is the default value
vector v1(5, 10);
Posted by: Guest on March-18-2021

Code answers related to "initialize a vector with values c++"

Browse Popular Code Answers by Language