Why is a C++ Vector called a Vector?

后端 未结 16 2374
情话喂你
情话喂你 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 07:54

    Just to say why it probably isn't called array: Because std::vector has a dynamic size. An array conceptually is fixed in length. Next C++ Standard by the way has a std::array template, which is fixed in size and should be preferred over a plain array:

    std::array f = { 1, 2, 3, 4 };
    

提交回复
热议问题