What is the main disadvantage of std::vector?

0 like 0 dislike
7 views
What is the main disadvantage of std::vector?


This question I asked a couple of years ago in the interview. I have listed several disadvantages, but, according to sobesedovanija, the main drawback was not called. Several years passed, but the answer to this question, I did not "invented". Or is it a trick question was that?
by | 7 views

6 Answers

0 like 0 dislike
And what are the disadvantages you already mentioned?
by
0 like 0 dislike
I apologize
that's better
\r
\r
std::vector v = { 1, 2, 3.456, 99.99 }; 
by
0 like 0 dislike
For a long time is initialized.
by
0 like 0 dislike
The main drawback of the vector to reallocate.
This is exactly that basic, I would even say the root, but you can create in advance prevysheny size. Often helps.
That he has a long initialization — not even know — nedmalloc ( and company ) will rescue fathers of Russian democracy.
by
0 like 0 dislike
for example a couple of years ago it was impossible to initialize with
by
0 like 0 dislike
If you compare a vector with an ordinary array, that is, in my opinion, 2 major drawbacks:
1) the Speed of vectora in General
2) memory footprint compared to the conventional array
Of course in some cases these things can be neglected, but it can be very critical. Also, all naturally depends on straightness of hands of the programmer, as the possession of the STL in General requires considerable knowledge and skills.
by

Related questions

0 like 0 dislike
1 answer
asked May 3, 2019 by Neonoviiwolf
0 like 0 dislike
3 answers
0 like 0 dislike
3 answers
asked Apr 1, 2019 by askogorev
0 like 0 dislike
3 answers
0 like 0 dislike
4 answers
asked Mar 26, 2019 by Monnoroch
110,608 questions
257,186 answers
0 comments
28,862 users