Collections

Hello Experts...

I come from VB, And I remember using collection.

Well... I would need to use them in C++, (if possible).
I mean... Supouse that I defined a class like this

Class CTheClass

{
CTheClass ()
{
      Here goes the code for the constructor
};

int Member1;
int Member2;
char *Member3;

void MemberFunction(Param)

};

Well...

I will use an array of objects CTheClass, but while I write the program, I don't know how many object will I need... Then... I'd like to use something like those collections that I have used
in Visual Basic... Is there something like that in C++?.

I know that MFC has a class colection or something like that... But. What if I don't use MFC?.
I mean... programming in VC++ on Windows directly...

Thanks at all...
LVL 1
MarscAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MarscAuthor Commented:
Edited text of question.
0
yonatCommented:
What you are looking for is called STL - the Standard Templates Library. It includes the collections vector, deque, list, set, map, multiset and multimap. To use them, #include the standard headers <vector>, <deque>, <list>, <set> ot <map>.

To learn about the STL, see:
http://www.sgi.com/Technology/STL/stl_introduction.html

http://www.objectplace.com/technology/articles/9508.shtml

http://www.eckelobjects.com/stlsimpl.html

http://www.cs.brown.edu/people/jak/proglang/cpp/stltut/

http://www.infosys.tuwien.ac.at/Research/Component/tutorial/prwmain.htm

http://www.cpsc.ucalgary.ca/~kremer/STL/monitor/index.html

http://web.ftech.net/~honeyg/articles/eff_stl.htm


(No, you don't have to read *all* of these :-)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
captainkirkCommented:
There are also other collection classes such as CObList, CTypedPtrList, etc, but the STL approach I believe is supposed to be more type-safe...
0
jasonclarkeCommented:
> STL approach I believe is supposed to be more type-safe

.... but the big advantage of the Standard Template Library is that it is *Standard*, i.e. it is (or should be) available on all C++ compilers.

....and you have access to all the STL algorithms

....and you can easily write your own STL compliant containers/iterators and algorithms.

....and it introduces the a whole new 'generic' programming concept to C++ - the STL way of doing things is not really OO.

....it works well with built in types and can be very efficient.

And it is as type safe as anything is in C++.
0
MarscAuthor Commented:
Thanks...
I didn't try all this stuff yet... But I've been reading, and it is sure what I was looking for.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.