[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 295
  • Last Modified:

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...
0
Marsc
Asked:
Marsc
1 Solution
 
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
 
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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now