Please any one tell me what is vector in c++ ??? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 2

Please any one tell me what is vector in c++ ???

I want know the vector meaning and the use of it. And note that I am a beginner.(sorry for any spelling mistakes)

21st Jan 2018, 12:58 AM
Subrahmanya Mayya
Subrahmanya Mayya - avatar
3 Respostas
21st Jan 2018, 6:33 AM
Hatsy Rei
Hatsy Rei - avatar
+ 6
Vector is a type of container. The SoloLearn course wonā€™t cover this. It is similar to an array, but you donā€™t have to worry about a maximum number of elements. For example: #include <iostream> #include <vector> using namespace std; int main() { //this makes a vector of integers named vec. It is currently empty. vector<int> vec; //this adds 3 items to it: 3, 8, 479. vec.push_back(3); vec.push_back(8); vec.push_back(479); //you can access vectors just like arrays. vec[1] = 56; cout << vec[0] << endl; cout << vec[1] << endl; cout << vec[2] << endl; } Outputs: 3 56 479
21st Jan 2018, 1:51 AM
Jacob Pembleton
Jacob Pembleton - avatar
+ 1
its a dynamic array, it can adjust its size
21st Jan 2018, 3:09 AM
shobhit
shobhit - avatar