In the early years there was no standard for C++ and all compiler vendors followed only a rough convention of what should be there. But often you couldn't port a program from one compiler/platform easily to another because of annoying little differences. So the high knights of C++ sat down at a round table, discussed a lot and wrote a standard call ISO-C++. It's also known as standard C++, C++98 or most formal: ISO/IEC 14882:1998
In it many of the old header files were standardized so that a given set of instructions could be used regardless of which compiler you use. To differentiate between the old headers and the new ones, the .h was removed from them. So #include <iostream.h> is now just #include <iostream> as well as many others.
As well as the new headers was the inclusion of the standard namespace. Any objects in the new header files, such as cout and endl, are found in the namespace std, and can be accessed either individually:
- Code: Select all
#include <iostream>
void f() {
std::cout << "BLAH" << std::endl;
// note: standard library identifiers are to be prefixed with std::
}
or individually imported from the namespace std:
- Code: Select all
#include <iostream>
using std::cout;
void f() {
cout << "BLAH" << std::endl;
// note: prefix std:: not neccesary for cout, but for endl
};
Or everything from the namespace std gets imported, by putting the following line under your includes (not recommended for writing header files)
- Code: Select all
#include <iostream>
using namespace std;
void f() {
cout << "BLAH" << endl;
// note: prefix std:: not needed at all
};
Then just use cout as normal, without the std:: in front.
Namespaces are useful, but for a beginner who doesn't need to worry about them, just put the using namespace std line under your includes, and you shouldn't need to worry about it for now, just do some reading when you get the chance.
The C++ standard headers are:
- <algorithm> Many useful algorithms, like std::copy
- <bitset> Bitset
- <complex> Complex numbers
- <deque> Deque containters
- <exception> Exception handling
- <fstream> File IO
- <functional> Function objects
- <iomanip> IO manipulators
- <ios> IO base classes
- <iosfwd> IO forward declarations
- <iostream> IO streams
- <istream> Input streams
- <iterator> Useful iterators, like std::ostream_iterator
- <limits> Implementation properties
- <list> List containers
- <locale> I18 Locales
- <map> Assiociative containers
- <memory> Memory managment
- <new> Dynamic memory management
- <numeric> Numeric limits
- <ostream> Output streams
- <queue> Queue containers
- <set> Set containers
- <sstream> String streams
- <stack> Stack containers
- <stdexcept> Exception classes
- <streambuf> Stream buffer classes
- <string> String classes
- <typeinfo> Type identification
- <utility> Utility component
- <valarray> Arrays of values
- <vector> Vector containers
- <cassert> adapted assert.h from C
- <cctype> adapted ctype.h from C
- <cerrno> adapted errno.h from C
- <cfloat> adapted float.h from C
- <climits> adapted limits.h from C
- <clocale> adapted locale.h from C
- <cmath> adapted math.h from C
- <csetjump> adapted setjump.h from C
- <csignal> adapted signal.h from C
- <cstdarg> adapted stdarg.h from C
- <cstddef> adatped stddef.h from C
- <cstdio> adapted stdio.h from C
- <cstdlib> adapted stdlib.h from C
- <cstring> adapted string.h from C
- <ctime> adapted time.h from C
- <cwchar> adapted wchar.h from C
- <cwctype> adapted wctype.h from C
- http://www.cppreference.com/ Quite nice, covers the most commoned used things
- http://www.cplusplus.com/ref/ Covers only few of the headers.
- http://gcc.gnu.org/onlinedocs/libstdc++/documentation.html Lots of information
- http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcstdlib/html/vclrfcpluspluslibraryoverview.asp MS's docu to the VC++ standard libraries
- http://www.sgi.com/tech/stl/ A lot of info, but remember: SGI STL is only similar to the C++ standard library, it's not the same
- http://www.dinkumware.com/manuals/reader.aspx?lib=cpp Docs for the Dinkumware implementation of the C++ library
Thanks to Wizard, who posted the initial version.
As always: Corrections welcome ;-)
Changes:
Added link to GNU libstdc++ docu
