Solved

[noob][c++]  what is a container?

Posted on 2007-11-16
6
196 Views
Last Modified: 2010-04-01
what is a container?
0
Comment
Question by:Troudeloup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 14

Assisted Solution

by:cuziyq
cuziyq earned 100 total points
ID: 20299637
A container is a set of data wrapped up in a class.  A linked list is an example of a container class.
0
 
LVL 30

Assisted Solution

by:Axter
Axter earned 250 total points
ID: 20299657
A container is a class that stores multiple objects of the same type.
0
 
LVL 30

Accepted Solution

by:
Axter earned 250 total points
ID: 20299666
Example containers:
std::vector
std::list
std::deque
std::map
std::set

Some would also consider std::string a container.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 39

Assisted Solution

by:itsmeandnobodyelse
itsmeandnobodyelse earned 150 total points
ID: 20299695
To add to above information:

By using template containers you can store any arbitrary type. The most used container class is std::vector which is a dynamic array class. A special and very useful container is std::map whic is a so-called dictionary. A dictionary has a key and data type, which were stored as a pair. A dictionary provides a fast access to the data via the key.

Regards, Alex
0
 
LVL 30

Expert Comment

by:Axter
ID: 20300263
FYI:
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.
0
 

Author Comment

by:Troudeloup
ID: 20300540
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question