I am trying to learn C++ through on-line tutorials and such. In almost all tutorials, the author tells you which headers to include for that particular exercise, but never tells you how he knows that. I understand that if you are advanced enough to be writing tutorials, you know off the top of your head that you need #include <fstream> for file handling, but what about those that are still learning? In Python, I can open an interactive terminal and enter 'help()' and then 'modules' to get a list of modules available on my system. Enter the module name and I get a man page or at least an idea of what that module does and how to use it. So my question is, how does one find out what each header does and how it might be implemented. I could google each thing I'm trying to do (like random()), but I don't always have access to the internet.

Recommended Answers

All 5 Replies

As I'm still learning in college, we don't get explained of all of them either. But basically you will need to #include <iostream> for your cin and cout.
Then also there is other headers that you can use such as #include <iomanip> to set width,length or set how many decimal points to display. #include <cmath> for you math stuff like squareroot. #include <string> to use string variable , #include <fstream> for file handling.

Then as u learn later on programmers can make their own headers.

As said, if you look on any page at http://www.cplusplus.com/reference/ say this one on vector for example, you will find in the top right corner the #include needed for this class or function (in the case of vector, it is #include <vector>, if that wasn't obvious enough already).

I guess I got spoiled with Python documentation. The information in http://www.cplusplus.com/reference/ looks helpful. It would be nice to get all that in a .pdf or something so I can store it locally. It's still kind of vague though. Thanks for the input guys.

For an offline version, you can probably google around and find some version of it (might not be the exactly appropriate one, but it usually should be). For example, here you can download all the STL documentation in a zip or tarball (as offline html files) (it doesn't include iostreams and string functions and classes, only STL containers and algorithms).

EDIT: I also found this one which seems to be fairly complete, recent enough and from a trusted source (IBM).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.