CPSC
427a:
Object-Oriented
Programming
Michael
J.
Fischer
Lecture
2
September
7,
2010
subsection in toc
subsection in toc
subsection in toc
C++ Overview
General
properties
of
C++
-
Widely
used
in
the
real
world
-
Close
to
the
machine
-
Gives
programmer
fine
control
over
use
of
resouces
-
Supports
object-oriented
programming
paradigm
-
Supports
modularity
and
component
isolation
-
Supports
reusabale
code
through
derivation
and
templates
C/C++ comparison]Comparison of C and C++
C++
Extends
C
-
C++
grew
out
of
C.
-
Goals
were
to
improve
support
for
modularity,
portability,
and
code
reusability.
-
Most
C
programs
will
compile
and
run
under
C++.
-
C++
replaces
several
problematic
C
constructs
with
safer
versions.
-
Although
most
old
C
constructs
will
still
work
in
C++,
they
should
not
be
used
in
new
code
where
better
alternatives
exist.
Example:
Use
Boolean
constants
true
and
false
instead
of
1
and
0.
Some
Extensions
in
C++
-
Comments
//
(now
in
C99)
-
Executable
declarations
(now
in
C99)
-
Type
bool
-
Enumerated
types
-
Reference
parameters
-
Definable
type
conversions
-
Operator
extensions
-
Generic/overloaded
functions
-
Name
hiding
-
Classes
Tools
Low-level
-
A
text
editor
such
as
emacs
or
vi.
-
The
compiler
suite:
g++.
-
Project
management:
make
Eclipse IDE (integrated development environment)
-
Integrates
various
low-level
tools
-
Open
source
-
Works
on
many
platforms
-
Facilitates
development
cycle
Generic
Insertion
Sort
Two implementations of simple insertion sort:
-
C
version:
Written
in
object-oriented
style
to
the
extent
possible
in
C.
-
C++
version:
Similar
code
but
with
C++
support
C
version
See code demo.