Set type in C++
I'm playing aground with some algorithms that use set will give the program clearer. For example, init a setA, after that, give some query like:
<put a into setA><delete a in setA>
<does a in setA> <does a not in setA>.....
Pascal has this data structure, but I don't know does it exist on C++, and how to use it.
please help me, please
You can #include <set> and use a std::set<T>, where T is the type of objects that you intended to store in the set.
I convert from Pascal to C/C++, so I have never use STD Library before. After I read about "set" on Wiki, they declare it begin with word: "template". And I google for what mean of "template", and OMG, they have many/many results about templates, each result say many/many things about it. It made me dizzy :(
So, who can tell me simple, or give me some hint(links,note...) about template and how to use them, please :( I'm feeling very sick, now :|
For std::set take a look at: std::set reference
Originally Posted by hqt
As for C++ and templates, you should really read through a book about C++ vice just jumping right into it. However we do have a good brief tutorial: Templates in C++
You don't need to worry about the "template" part. It's just how it's declared and not how it's used.
laserlight gave an example on how to create a set.
Aside from that, if you want to know more, I think you should get a good book such as Accelerated C++ to journey into C++.
OMG, after a long week playing aground with class,template,public,private,...(and many other keywords, maybe just have in OOP programming), at now, I have a new lesson, that I newly learnt: You don't need to know anything above(template,class...) to understand and use STD C++ library :(.
On long road to have above statement, I see another funny point: the most effective document are not recommend C++ book lists on many sites I found. The easiest way to learn is lecture of many universities I have googled. For example: MIT, and standford. They are short, easy to understand, and specially, always say to focus point. (at least, because they write for student :D)
At all, thank for all people here have given a vision how to learn C++ (although there a long way from know to understand :( ) :)
Yes, at least for many of the common uses for the standard library.
Your mileage may vary for course material. Good academics are not necessarily good teachers, even if they genuinely are interested in teaching. Speaking of Stanford though, I recommend Accelerated C++, which has course material from a Stanford course involving C++ as a precursor.