Why is a C++ Vector called a Vector?

后端 未结 16 2366
情话喂你
情话喂你 2020-12-04 07:42

The question\'s pretty self-explanatory really. I know vaguely about vectors in maths, but I don\'t really see the link to C++ vectors.

相关标签:
16条回答
  • 2020-12-04 08:07

    To complement the excellent response from @MarkRuzon:

    Alex said that to give a name to what is now called std::vector he observed the name that Scheme and Common Lisp ​​had given to similar data structures.

    Later he admits he was wrong because C++ vector has nothing to do with the vectors in mathematics.

    He also says that he introduced an error of a community of 50 people to a community of 5 million people, so the error is likely to remain forever.

    0 讨论(0)
  • 2020-12-04 08:08

    Also if you make it store integers or floating points it does make an excellent type for storing N dimensional vectors. After all all a vector is, is a list of numbers kept in a specific order.

    0 讨论(0)
  • 2020-12-04 08:10

    No idea about the real reason, but C++ calling it a vector instead of an array, reduces confusion between the C and C++ structures, although they fulfill the same roles.

    0 讨论(0)
  • 2020-12-04 08:12

    Mathematical definition of a vector is a member of the set Sn, which is an ordered sequence of values in a specific set (S). This is what a C++ vector stores.

    0 讨论(0)
提交回复
热议问题