can someone help me with what STL is? I mean i have a program but i am not sure on how to implement it using STL containers like which type of STL container and algorithm it uses?
It is a shorthand for Standard Template Library. Some time ago, in dark ages, when there weren't so many standard containers, algorithms and stuff, some guy had created a template library to work with anything. It was so popular, that it was included in standard later. Now STL doesn't exist as a separate entity. Some people calls templated part of standard library STL, but it is not correct.
Wikipedia has a search feature as well. If you don't like Google make sure to block googlesyndication.com and google-analytics.com that runs on this site.
Thank you all for replying.. I understood the concept of STL the only thing that is not clear to me is in a normal program how can i add STL container?
I mean i have a program which is without STL now need to add one STL container don know how to do an someone guide me with it please..
std::vector is an STL container. std::array, std::list, std::map, std::deque, std::set, std::forward_list, std::unordered_map, std::unordered_set, all of these are STL containers.
I mean i have a program which is without STL
STL is a part of standard library now. I bet you already have part of something which were in STL before in your program already.
The STL includes several container classes, with different properties. Your first step should be to read the basic descriptions of them, and decide which one is most suitable for whatever it is that you want to use it for.
There's plenty of documentation about them on this site.
hash_map was a part of original STL. It is that standard comitee doesn't adopt it until C++11.
As I understand it, hash_map was an extension to the STL provided by many C++ implementations, but wasn't formally part of the standard until the unordered_map class was introduced as part of TR1 and then C++11.
Edit: Actually, it's more correct to say that hash_map wasn't part of the Standard C++ Library. The STL documentation at http://www.sgi.com/tech/stl/ includes hash_map.
STL was external library, that was later incorporated in standard C++. AFAIR HP implementation was first. STL does not exist officially in C++ standard. This is just a name some people calls parts that were influenced by original STL.
There were quite a few things in STL that weren't included in C++. I loved the compose and select functors, power() (which I still have to write by hand every time) and iota() which made a comeback for C++11.
Many general-purpose C++ libraries back then (1992-1998) had containers (including hash maps of course), iterators, and some sort of algorithms, but STL had the best design and the smallest scope (no threads, strings, I/O, or date/time like the others)
But this thread really ran off course. OPs question was "i have a program but i am not sure on how to implement it using containers and algorithms", and it's impossible to answer without the program in question, or at least a detailed description of what it does.
@MiiNiPaa and MickeyBoy-- thank you for giving me the concept of the STL it vil surely help me..
@Cubbi-- Actually you are right i need to what the program actualy is and how STL is impelemented..
Here is the code for counting the occurrence of words and please do help me in knowing how can i add STL container and algorithm in it...
@Cubbi-- thank u so much for the help.
But i am unable to debug the program with some errors;
Could u please help me with it.
I am running the program using visual studio 2010...
error C2143: syntax error : missing ',' before ':'
.cpp(16): error C2143: syntax error : missing ',' before ':'
.cpp(16): error C2530: 'p' : references must be initialized
.cpp(16): error C3531: 'p': a symbol whose type contains 'auto' must have an initializer
.cpp(17): error C2228: left of '.first' must have class/struct/union
1> type is 'int'
.cpp(17): error C2228: left of '.first' must have class/struct/union
1> type is 'int'
.cpp(18): error C2228: left of '.second' must have class/struct/union
1> type is 'int'
1>
1>Build FAILED.