Course Info
-
1 credit class,
with the grade reported as Credit
or No Credit
-
Credit received for
- Attendance at 10 or more of the 14 lectures
(Sign your name on the provided paper each class.)
- Completion of all assignments
More Course Info
-
NO Required Textbook
Get a C++ reference.
-
Programs must work correctly as compiled
on our Unix machines.
You have an account.
-
Where to get help?
- TA
- Karen
- form a study group
Course Goals
-
Become familiar with many aspects of C++
-
Understand that the language is too large
to keep all aspects/syntax in your head
Note that with a 1-credit class,
time permits breadth coverage, not depth.
The History: C
-
designed by Dennis Ritchie in the 1970's
at Bell Labs
-
a new language for systems programming,
specifically to implement the evolving
Unix operating system
(to avoid writing O.S. code directly in
assembly language)
-
language goal: efficient compiled code
Java
-
designed from scratch in 1990's
-
object oriented (OO)
-
designed around the safety of
the programmer
-
should be platform-independent
-
uses much the same syntax as C
C++
-
designed in the 1980's (also at Bell Labs)
by Bjarne Stroustrup
-
a superset of C, to include OOP
-
language goal:
the programmer should never have to pay for
language features not used
A Program's Development Cycle
-
Edit source code
- Unix editors are vim and gvim, emacs,
pico, etc.
- name source code files with suffix of
.cpp, .cc, or .C
(Use .cpp for this class.)
-
Compile
% g++ myprogram.cpp
places the executable into a file called a.out
-
Execute program
% a.out
- Terminology
| Java |
classes |
fields |
methods |
| C++ |
classes |
data members |
member functions |
- C++ also has free functions,
functions that do not belong to a class
main() is a free function
- every program must have
main(),
as it is where program execution begins
A First Program
#include <iostream>
using namespace std;
// a comment, in my first program
int main () {
cout << "Good morning" << endl;
int a;
a = 12;
cout << "a = " << a << endl;
return 0;
}
Data Types
- integer types
int,
short,
long,
unsigned int,
unsigned short,
unsigned long,
char,
signed char,
unsigned char,
bool (true is 0,
and false is non-zero)
- floating point types
float (single precision floating point)
double (double precision floating point)
long double
Copyright © Karen Miller, 2009