Why & Is Typed After Vector In C++ Code Example


Example: declare vectors c++

vector<int> vec; //Creates an empty (size 0) vector    vector<int> vec(4); //Creates a vector with 4 elements.  /*Each element is initialised to zero. If this were a vector of strings, each string would be empty. */  vector<int> vec(4, 42);  /*Creates a vector with 4 elements. Each element is initialised to 42. */   vector<int> vec(4, 42); vector<int> vec2(vec);  /*The second line creates a new vector, copying each element from the vec into vec2. */

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable