-3

Recently, I've started learning vector. I can't understand a syntax in vector. I googled it but couldn't find any satisfied answer.

std::vector<int> path;  
std::vector<int> newpath(path);

Can anyone explain this?

Ron
  • 14,674
  • 4
  • 34
  • 47

1 Answers1

0

The second line copy-constructs a new std::vector<int> instance from path. Thereafter both vectors store identical data.

Walter
  • 44,150
  • 20
  • 113
  • 196
lubgr
  • 37,368
  • 3
  • 66
  • 117
  • Is _identical_ a reserved terminology for objects having equal salient non-salient objects? I meant value-equality in terms of `operator ==`, where `capacity()` and `data()` doesn't come into play. But I'm happy to adjust the wording if `identical` actually means something different. – lubgr Aug 08 '18 at 08:55
  • I think the word you're after is *equivalent*, i.e. compare equal with `operator==`. – Walter Aug 08 '18 at 08:57
  • @Walter Thanks for the fix! I don't know whether _equivalent_ is the right word either, though. Equality is a form of equivalence, but not the only one. I guess _equality_ is the best term here. – lubgr Aug 08 '18 at 09:01