Escolar Documentos
Profissional Documentos
Cultura Documentos
• Phần mềm
– Hướng dẫn lệnh cho máy tính thực hiện hành động và quyết
định
• Phần cứng
• Phiên bản chuẩn hoá của C++
– Mỹ
• Viện tiêu chuẩn quốc gia Mỹ (ANSI)
– Quốc tế
• Tổ chức tiêu chuẩn quốc tế (ISO)
• Lập trình theo cấu trúc
• Lập trình hướng đối tượng
• Máy tính
– Thiết bị có thể biểu diễn các thao tác điện toán và thực hiện
các quyết định logic
• Các chương trình máy tính
– Bộ các lệnh hướng dẫn điều khiển việc xử lý dữ liệu của
máy tính
• Phần cứng
– Máy tính gồm rất nhiều thiết bị bên trong
• Keyboard, màn hình, chuột, đĩa, bộ nhớ, CD-ROM, bộ xử lý,
…
• Phần mềm
– Các chương trình chạy trên máy tính
• 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++!
• Tên biến
– Tương ứng với vị trí thực đặt trong bộ nhớ máy tính
– Mọi biến đều có tên, kiểu, kích cỡ và giá trị
– Khi biến được gán cho 1 giá trị mới, sẽ viết đè lên giá trị cũ
– Đọc biến từ memory nondestructive
integer1 45
sum = integer1 + integer2;
integer2 72
sum 117
1.24 Số học
1.24 Số học
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