You are not logged in. Please login at to post your questions!


Learn C++ and STL


I am doing competitive programming in C++ from quite some time now . But I do not use any features and benefits that C++ provides over C . I would like to learn C++ to become a good programmer . I think there is STL library for C++ but I am not sure. Please help me how to learn C++ and STL.

asked 28 Jun '14, 17:52

the65bit's gravatar image

accept rate: 13%

edited 29 Jun '14, 01:31


STL library is surely there.

(28 Jun '14, 17:58) yash_155★

For what purpose STL is used . Also it would be very helpful if you could provide reference to learn it .

(28 Jun '14, 18:02) the65bit4★

One example : you might have learnt bit about stacks, queues, etc then you would have observed that push(),pop(),etc are needed to use these concepts. In STL, you just declare a stack, and an empty stack is ready for you. You can use it simply like a.push_back(5) to add 5 to the stack!

The standard reference site is

(28 Jun '14, 18:47) yash_155★

Is there a good book on STL and also is there a need for a book ?

(02 Jul '14, 19:25) the65bit4★

  1. Include < bits/stdc++.h >
  2. Use namespace std
  3. For sorting array a[100], use sort(a,a+100);
  4. Use C++ reference website to look up the the containers like pair and map.

answered 28 Jun '14, 17:57

yash_15's gravatar image

accept rate: 2%

Thanks . For what bits/stdc++.h is used . For sorting I think algorithm library also provide a simlar function .

(28 Jun '14, 18:01) the65bit4★

bits/stdc++.h is a complete header file. If you have seen some experts writing a whole page of includes, then all those, and probably even more, get included in your code.

Right from iostream, stdio to iomanip, math to list,queue,map,vector,algorithm etc.

This file is like an includer file.

(28 Jun '14, 18:41) yash_155★

There are multiple sources where you can learn STL from. Google stl tutorials and you'll get a thousand tutorials. Have a look at the first few and choose one. Stick with it. i'd reccomend doing tha chapter 16 "The Standard Template Library" on this website

Download a cheat sheet on STL, it'll give you all the functions that are available in the STL. Go though the link given by yash_15 in the comments (of the question).

Once you've gone through a full tutorial (or half, if you're lazy like me :P ), look at people's submissions and look at what STL related functions they use and start using them.

If you're coming from C background, i'd suggest going through some C++ tutorial just to get an idea what is there in C++.

In terms of competitive programming, there's not much difference as you don't use classes/constructors etc when solving a problem. Although if you're using malloc to declare memory, then stop using that and use int *i = new int;

TL;DR: Google and learn

Happy coding!!


answered 29 Jun '14, 05:03

tacoder's gravatar image

accept rate: 18%

edited 29 Jun '14, 05:04

Thanks @tacoder

(29 Jun '14, 13:48) the65bit4★

topcoder also lists a nice collection of tutorial for stl link1 & link2


answered 29 Jun '14, 15:03

bug2312's gravatar image

accept rate: 12%

Thanks @bug2312

(29 Jun '14, 20:57) the65bit4★

Best reference i have found is

where you can find all stl functions at one place explain with proper examples. Hope i help you! Cheers :)


answered 29 Jun '14, 15:51

tech_boy's gravatar image

accept rate: 7%

Thanks @tech_boy

(29 Jun '14, 20:57) the65bit4★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 28 Jun '14, 17:52

question was seen: 8,201 times

last updated: 02 Jul '14, 19:25