Introduction to C++
- For the bulk of the remainder of the semester, we will be programming in
C++. (So start bringing your C++ book to recitation) When I say
``Programming in C++'', I'm referring to the process of
writing C++ source code (via some text editor), compiling it, debugging
it, and running it.
- You should understand (within the next few weeks)
the edit/compile/debug cycle as well
as the difference between syntax errors and logical errors.
- You already know how to edit a file. You did so with the
HTML stuff we've been doing. So far, we've been editing a file
called ``index.html''. Now were going to create and edit other
files. The HMTL files we've been working with ended with ``.html'' but
now the files will end with ``.C'' (that's a dot followed by a
capital letter ``C''). These are our ``C++'' programs. These are
also our ``source code'' files - the files that contain the actual
C++ code. The file is pure text just like your HTML files.
- We created HTML files and then saw what they did by looking at
them with Netscape. It's a little different in C++. We have to convert
our source code (the stuff in the ``.C'' file) to a language that
the computer can understand directly. This conversion process is
called ``compiling'' and the program that does this compiling is called
a ``compiler''. The compiler we will be using is ``g++''. g++
will convert our source code to ``executable'' code, or ``object'' code.
Once this is done, we can just type in the name of the executable file
and the program will run.
- C++ is case sensitive, meaning that an uppercase letter or
character is indeed different from a lowercase character. HTML was
not case sensitive for the most part. C++ is
not sensitive to whitespace characters (neither was HTML).
This means that two spaces
in a row are ignored. You can even write your entire program without
ever pressing return. Tabs are also ignored. So basically,
redundant spaces, tabs,
and return characters are all ignored unless they are a part of a character
string. (I'll explain later).