Troudeloup
asked on
[noob][c++] what is a container?
what is a container?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many developer make the mistake of using std::list as they're default container.
For most requirements std::vector is more efficient then std::list.
Moreover, the C++ standard recommends using std::vector as the default container.
In general, std::list should only be used when you need to remove or add content from the center of the container.
std::deque should be used if you need to add or remove content from the start (beginning) of the container, but don't need to add/remove content from the center.
std::vector should be the default container, since for most requirements, you only need to add/remove content from the end of the container.
Some experts recommend using std::vector, even when you need to add/content from the start or middle of the container when the add/remove action is not accessive.