Why use QVector(Qt) instead of std::vector

后端 未结 6 1608
面向向阳花
面向向阳花 2020-12-13 12:31

I\'m very new to C++ and Qt, but I\'m very good at C#/Java.

The point is I like cross-platform, but I\'m confuse with Qt. Isn\'t std::vector already cro

6条回答
  •  醉话见心
    2020-12-13 12:36

    C++'s std::vector is cross-platform because it is part of the C++ Standard. Every C++-conformant compiler must provide it.

    I'm not familiar with Qt, but I did see this in the docs:

    Note: All functions in this class are reentrant.

    It's also likely (speculation) that the QVector class is more easily integrated to hold Qt-centric objects than std::vector might be. Again, I'm not familiar with Qt so you have to decide for yourself.

    As a rule of thumb (to which there are many exceptions), I would tend to use std::vector unless I had a compelling reason to use some library-specific container class.

提交回复
热议问题