Académique Documents
Professionnel Documents
Culture Documents
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
• Computer
– Device capable of performing computations and making
logical decisions
• Computer programs
– Sets of instructions that control computer’s processing of
data
• Hardware
– Various devices comprising computer
• Keyboard, screen, mouse, disks, memory, CD-ROM,
processing units, …
• Software
– Programs that run on computer
• Early computers
– Single-user batch processing
• Only one job or task at a time
• Process data in groups (batches)
• Decks of punched cards
• Operating systems
– Software systems
– Manage transitions between jobs
– Increased throughput
• Amount of work computers process
• Multiprogramming
– Many jobs or tasks sharing computer’s resources
– “Simultaneous” operation of many jobs
• Timesharing
– 1960s
– Special case of multiprogramming
– Users access computer through terminals
• Devices with keyboards and screens
• Dozens, even hundreds of users
– Perform small portion of one user’s job, then moves on to
service next user
– Advantage:
• User receives almost immediate responses to requests
• History of C
– Evolved from two other programming languages
• BCPL and B
– “Typeless” languages
– Dennis Ritchie (Bell Laboratories)
• Added data typing, other features
– Development language of UNIX
– Hardware independent
• Portable programs
– 1989: ANSI standard
– 1990: ANSI and ISO standard published
• ANSI/ISO 9899: 1990
• History of C++
– 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
• C++ programs
– Built from pieces called classes and functions
• C++ standard library
– Rich collections of existing classes and functions
• “Building block approach” to creating programs
– “Software reuse”
1.9 Java
• Java
– 1991: Sun Microsystems
• Green project
– 1995: Sun Microsystems
• Formally announced Java at trade show
– Web pages with dynamic and interactive content
– Develop large-scale enterprise applications
– Enhance functionality of web servers
– Provide applications for consumer devices
• Cell phones, pagers, personal digital assistants, …
• FORTRAN
– FORmula TRANslator
– 1954-1957: IBM
– Complex mathematical computations
• Scientific and engineering applications
• COBOL
– COmmon Business Oriented Language
– 1959: computer manufacturers, government and industrial
computer users
– Precise and efficient manipulation of large amounts of data
• Commercial applications
• Pascal
– Prof. Niklaus Wirth
– Academic use
Preprocessor Preprocessor program
1. Edit
Disk
processes the code.
Compiler creates
Compiler Disk object code and stores
2. Preprocess it on disk.
Linker links the object
Linker Disk code with the libraries,
3. Compile Primary
creates a.out and
stores it on disk
Memory
Loader
4. Link Loader puts program
in memory.
Disk
5. Load
Primary
6. Execute CPU
Memory
CPU takes each
instruction and
executes it, possibly
storing new data
values as the program
executes.
2003 Prentice Hall, Inc. All rights reserved.
28
1.14 Basics of a Typical C++
Environment
• Input/output
– cin
• Standard input stream
• Normally keyboard
– cout
• Standard output stream
• Normally computer screen
– cerr
• Standard error stream
• Display error messages
• TCP/IP
– Transmission Control Protocol (TCP)
• Messages routed properly
• Messages arrived intact
– Internet Protocol (IP)
• Communication among variety of networking hardware and
software
• Current architecture of Internet
• Bandwidth
– Carrying capacity of communications lines
Welcome to C++!
Welcome
to
C++!
• Variable names
– Correspond to actual locations in computer's memory
– Every variable has name, type, size and value
– When new value placed into variable, overwrites previous
value
– Reading variables from memory nondestructive
1.24 Arithmetic
• Arithmetic calculations
– *
• Multiplication
– /
• Division
• Integer division truncates remainder
– 7 / 5 evaluates to 1
– %
• Modulus operator returns remainder
– 7 % 5 evaluates to 2
1.24 Arithmetic
Relational operators
> > x > y x is greater than y
< < x < y x is less than y
≥ >= x >= y x is greater than or equal to y
Equality operators
= == x == y x is equal to y
≠ != x != y x is not equal to y