0

This is a C++ code vector initialization. vectorv(n,1). Here what does mean by 1? I know that n is the size of the vector. But what is the job of 1 here?

  • I expect that every good C++ textbook will explain what all of the constructors are, for one of the most frequently used templates. Is there something in your textbook's explanation, of this constructor, that's unclear to you? – Sam Varshavchik Sep 05 '20 at 13:56
  • 3
    The best solution to approach this kind of questions is to read the reference documentation first: https://en.cppreference.com/w/cpp/container/vector/vector – πάντα ῥεῖ Sep 05 '20 at 13:57
  • @πάνταῥεῖ there *are* a lot of constructors - so I *could* see how it might be tricky to spot which constructor would be used if you are not used to reading STL c'tors? - but then I guess the question could be re-worked to "which constructor is used?"... the duplicate answers suggest different c'tors... thoughts? – code_fodder Sep 05 '20 at 14:22

0 Answers0