Professional Documents
Culture Documents
2003 Prentice Hall, Inc. All Rights Reserved
2003 Prentice Hall, Inc. All Rights Reserved
Outline
1.1
Introduction
1.2
What is a Computer?
1.3
Computer Organization
1.4
Evolution of Operating Systems
1.5
Personal Computing, Distributed Computing and
Client/Server Computing
1.6
Machine Languages, Assembly Languages, and High-Level
Languages
1.7
History of C and C++
1.8
C++ Standard Library
1.9
Java
1.10
Visual Basic, Visual C++ and C#
1.11
Other High-Level Languages
1.12
Structured Programming
1.13
The Key Software Trend: Object Technology
1.14
Basics of a Typical C++ Environment
1.15
Hardware Trends
2003 Prentice Hall, Inc. All rights reserved.
Outline
1.16
1.17
1.18
1.19
1.20
1.21
1.22
1.23
1.24
1.25
1.26
1.1 Introduction
Software
Instructions to command computer to perform actions and
make decisions
Hardware
Standardized version of C++
United States
American National Standards Institute (ANSI)
Worldwide
International Organization for Standardization (ISO)
Structured programming
Object-oriented programming
2003 Prentice Hall, Inc. All rights reserved.
1.2
What is a Computer?
Computer
Device capable of performing computations and making
logical decisions
Computer programs
Sets of instructions that control computers processing of
data
Hardware
Various devices comprising computer
Keyboard, screen, mouse, disks, memory, CD-ROM,
processing units,
Software
Receiving section
Obtains information from input devices
Keyboard, mouse, microphone, scanner, networks,
2. Output unit
Shipping section
Takes information processed by computer
Places information on output devices
Screen, printer, networks,
Information used to control other devices
Manufacturing section
Performs arithmetic calculations and logic decisions
Administrative section
Supervises and coordinates other sections of computer
Operating systems
Software systems
Manage transitions between jobs
Increased throughput
Timesharing
1960s
Special case of multiprogramming
Users access computer through terminals
Devices with keyboards and screens
Dozens, even hundreds of users
Computer networks
Over telephone lines
Local area networks (LANs)
Distributed computing
10
Client/server computing
File servers
Offer common store of programs and data
Client computers
Access file servers across network
11
12
13
14
15
Extension of C
Early 1980s: Bjarne Stroustrup (Bell Laboratories)
Spruces up C
Provides capabilities for object-oriented programming
Objects: reusable software components
Model items in real world
Object-oriented programs
Easy to understand, correct and modify
Hybrid language
C-like style
Object-oriented style
Both
2003 Prentice Hall, Inc. All rights reserved.
16
Software reuse
17
1.9 Java
Java
1991: Sun Microsystems
Green project
18
Visual Basic
1991
Result of Microsoft Windows graphical user interface (GUI)
Developed late 1980s, early 1990s
Powerful features
GUI, event handling, access to Win32 API, object-oriented
programming, error handling
19
.NET platform
Web-based applications
Distributed to great variety of devices
Cell phones, desktop computers
20
Language interoperability
21
COBOL
COmmon Business Oriented Language
1959: computer manufacturers, government and industrial
computer users
Precise and efficient manipulation of large amounts of data
Commercial applications
22
23
Pascal
1971: Niklaus Wirth
Ada
1970s - early 1980s: US Department of Defense (DoD)
Multitasking
24
Software reuse
Libraries
MFC (Microsoft Foundation Classes)
Rogue Wave
2003 Prentice Hall, Inc. All rights reserved.
25
Program-development environment
Language
C++ Standard Library
26
Disk
Programiscreatedin
theeditorandstored
ondisk.
Disk
Preprocessorprogram
processesthecode.
Compiler
Disk
Compilercreates
objectcodeandstores
itondisk.
Linker
Disk
Editor
Preprocessor
4. Link
Loader
5. Load
Disk
6. Execute
Primary
Memory
Loaderputsprogram
inmemory.
..
..
..
Primary
Memory
CPU
..
..
..
Linkerlinkstheobject
codewiththelibraries,
createsa.outand
storesitondisk
CPUtakeseach
instructionand
executesit,possibly
storingnewdata
valuesastheprogram
executes.
27
cout
Standard output stream
Normally computer screen
cerr
28
Processor speeds
29
ARPAnet
Electronic mail (e-mail)
Packet switching
Transfer digital data via small packets
Allow multiple users to send/receive data simultaneously
over same communication paths
No centralized control
30
Bandwidth
31
32
Primary financing
Strategic direction
33
Working Draft
Specifies evolving draft
Candidate Recommendation
Stable version that industry can begin to implement
Proposed Recommendation
Considerably mature Candidate Recommendation
34
Portability
C and C++ programs can run on many different computers
Compatibility
35
Structured programming
Object-oriented programming
36
Document programs
Improve program readability
Ignored by compiler
Single-line comment
Begin with //
Preprocessor directives
37
1
2
3
4
5
6
7
8
9
10
11
12
Outline
Single-line comments.
returns an
directive to
integer
value.
Left brace
{ begins Preprocessor
function
fig01_02.cpp
include
input/output Statements
stream
begins
execution
body. program
end with a(1 of 1)
Function
main appears
header
file <iostream>.
exactly once
in every
C++ semicolon ;.
program..
fig01_02.cpp
// function main
int main()
{
std::cout << "Welcome to C++!\n";
return 0;
//
} // end function
Welcome to C++!
output (1 of 1)
3
8
Namespace
std:: specifies using name that belongs to namespace
std
std:: removed through use of using statements
Escape characters
\
Indicates special character output
2003 Prentice Hall, Inc. All rights reserved.
39
Description
\n
\t
\r
\a
\\
\"
40
1
2
3
4
5
6
7
8
9
10
11
12
13
Outline
fig01_04.cpp
Multiple stream insertion
(1 of 1)
statements produce one line of
output.
fig01_04.cpp
output (1 of 1)
Welcome to C++!
4
1
1
2
3
4
5
6
7
8
9
10
11
12
Outline
fig01_05.cpp
(1 of 1)
to
fig01_05.cpp
output (1 of 1)
Welcome
to
C++!
4
2
Comma-separated list
int integer1, integer2, sum;
2003 Prentice Hall, Inc. All rights reserved.
43
Valid identifier
Series of characters (letters, digits, underscores)
Cannot begin with digit
Case sensitive
44
= (assignment operator)
Assigns value to variable
Binary operator (two operands)
Example:
45
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Outline
fig01_06.cpp
(1 of 1)
// read an integer
Concatenating, chaining or
cascading stream insertion
operations.
4
6
Outline
fig01_06.cpp
output (1 of 1)
4
7
48
49
integer1
45
integer1
45
integer2
72
integer1
45
integer2
72
sum
117
1.24
Arithmetic
Arithmetic calculations
*
Multiplication
/
Division
Integer division truncates remainder
7 / 5 evaluates to 1
50
1.24
Arithmetic
Operator(s)
Operation(s)
Operators
applied fromOrder
leftoftoevaluation
right (precedence)
()
Parentheses
*, /, or %
+ or -
Addition
Subtraction
51
Relational operators
Same level of precedence
52
C++ equality
or relational
operator
Example
of C++
condition
Meaning of
C++ condition
Relationaloperators
>
>
x>y
xisgreaterthany
<
<
x<y
xislessthany
>=
x>=y
xisgreaterthanorequaltoy
<=
x<=y
xislessthanorequaltoy
Equalityoperators
==
x==y
xisequaltoy
!=
x!=y
xisnotequaltoy
53
54
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Outline
fig01_14.cpp
(1 of 2)
using statements eliminate
need for std:: prefix.
variables.
// function main begins programDeclare
execution
int main()
{
Can write
cin
int num1; // first number
to becout
read and
from
user
withouttostd::
prefix.
int num2; // second number
be read
from user
cout << "Enter two integers, and I will tell you\n"
if structure compares values
<< "the relationships they satisfy: ";
of num1 and num2
to test for
If condition
is true
cin >> num1 >> num2;
// read two integers
if ( num1 == num2 )
cout << num1 << " is
(i.e.,
equality.
values are equal), execute this
if structure compares
values
statement.
If condition
is true (i.e.,
of num1
andnum2
num2
test for
equal
to " <<
<< to
endl;
values are not equal), execute
inequality.
this statement.
if ( num1 != num2 )
cout << num1 << " is not equal to " << num2 << endl;
5
5
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Outline
fig01_14.cpp
Statements
may
(2 of
2) be split over
several lines.
fig01_14.cpp
output (1 of 2)
5
6
Outline
fig01_14.cpp
output (2 of 2)
5
7
Inheritance
New classes of objects absorb characteristics from existing classes
Objects
58
Member functions
Function components of class
Association
Reuse classes
59
60
61