OUR FIRST C++ class:
* a class is a way to make a new type! although some are
included with C++
* you learn about *writing* your own classes in CS 112,
but we'll *use* a few classes in CS 111
* string is a class in C++
* classes have their own function-like pieces
called methods
* when you declare a parameter or a named constant
to be of a type that is a class,
that parameter or constant is an instance
of that class
and that parameter or constant can use that class's methods!
* you can call a class instance's methods
using:
instance.method_name(arg_expr1, arg_expr2, ...)
* for example, say I have:
const string MY_NAME = "Sharon M. Tuttle";
* hey, string class has a length method
that expects nothing and returns the length
of the calling string!
MY_NAME.length() // call the length method of string
// MY_NAME
MY_NAME.length() == 16
* hey, string class has a + operator!
it lets you append either two string instances
OR a string and a char*!!
MY_NAME + MY_NAME == "Sharon M. TuttleSharon M. Tuttle"
MY_NAME + "!" == "Sharon M. Tuttle!"
* (yes, you can use == to compare a string and a char*,
fortunately! it returns true if they contain
the same characters...)