January 14, 2008
C++ and CS106 Library Reference
Written by Julie Zelenski.
You're sitting at your computer, trying to write some code that manipulates a string or
stream or draws some graphics.
You know the functionality you need probably exists in
one of the libraries, but don't remember the exact details.
The information might be in
the reader, but it's easy to get lost in there.
You could open the header file and check it
This works okay for our CS106 interfaces (which tend to be nicely
commented :-), but it is not so helpful for the standard headers which are often cryptic.
The web, of course, is filled with gobs of information, both handy and useless, so you
can probably find what you need there but you'll need to dig around some.
Then it occurred to me, how about I try to be helpful and pull together a quick summary
of the most commonly used functionality for handy reference?
And thus, this document
was born… This is a new handout, so let me know if you do find it useful and if so, what
errors/omissions I should correct for next time.
Note that this is intended as a quick
high-level overview, so if you need more in-depth details, check the reader/header
A couple of decent C++ web resources you might want to bookmark:
These can be useful for anything in standard C++, which includes the language itself and
all of its standard libraries (
The standard C++
The string class is defined in
type is actually a
shorthand. The underlying full name is
You don’t need to worry about this sort of low-level goop, but you will see the full name in
compiler error messages and will want to recognize it as such.
The default constructor initializes a string variable to the empty string, thus declaring a
string variable ensures that its contents start empty.
This is unlike the built-in types
, etc.) which have random contents until explicitly initialized. Assigning one