When would you use an array rather than a vector/string?

前端 未结 8 2046
醉梦人生
醉梦人生 2020-12-01 19:09

I\'m a beginner C++ programmer and so I\'ve learnt using arrays rather than vectors (this seems to be the general way to do things, then move on to vectors later on).

<
8条回答
  •  长情又很酷
    2020-12-01 19:48

    When writing code that should used in other projects, in particular if you target special platforms (embedded, game consoles, etc.) where STL might not be present.

    Old projects or projects with special requirements might not want to introduce dependencies on STL libraries. An interface depending on arrays, char* or whatever will be compatible with anything since it's part of the language. STL however is not guaranteed to be present in all build environments.

提交回复
热议问题