没有合适的资源?快使用搜索试试~ 我知道了~
首页C++编程速成:Sams Teach Yourself C++ in 21 Days 第5版精华
C++编程速成:Sams Teach Yourself C++ in 21 Days 第5版精华
4星 · 超过85%的资源 需积分: 10 4 下载量 100 浏览量
更新于2024-07-26
收藏 6.67MB PDF 举报
"Sams Teach Yourself C++ in 21 Days 5th Edition 是一本由Jesse Liberty和Bradley Jones合著的C++编程教程,旨在帮助读者在21天内掌握C++语言。该书由Sams Publishing出版,于2005年发行第五版。"
在这本C++教程中,作者们旨在通过一个紧凑的学习计划,让读者快速地理解并熟练运用C++编程语言。C++是一种强大的、面向对象的编程语言,它在软件开发、系统编程、游戏开发等领域有着广泛的应用。书中的内容可能涵盖了基础语法、数据类型、控制结构、函数、类和对象、模板、异常处理、输入/输出流以及更多高级主题。
"Teach Yourself in 21 Days"系列的特点是将复杂的学习内容分解成每天可消化的部分,使得学习过程更为有序和高效。这样的结构鼓励读者每天专注于特定的主题,通过实践和练习来巩固理论知识。
尽管书中的信息量大且全面,但作者和出版社明确指出,他们对书中可能出现的错误或遗漏不承担任何责任,也不对因使用书中信息导致的损害负责。这是出版行业的标准免责声明。此外,书中的商标和服务标记都得到了适当的尊重,但出版社并不确认这些商标的准确性,这强调了尊重知识产权的重要性。
本书的国际标准书号(ISBN)为0-672-32711-2,图书馆国会编目卡号为2004096713,表明它在全球范围内都是可识别和可索引的。这本书在美国印刷,表明其具有高质量的制作标准。
"Sams Teach Yourself C++ in 21 Days 5th Edition"是一本适合初学者和有一定经验的程序员的C++教程,它提供了一个系统化的学习路径,帮助读者在短时间内掌握C++编程的核心概念和技术。通过每日的练习和逐步深入,读者可以期望在21天内建立起坚实的语言基础,并具备进一步探索C++高级特性的能力。
Friend Functions and Operator Overloading ......................................................580
Overloading the Insertion Operator ....................................................................585
Summary..............................................................................................................589
Q&A ....................................................................................................................590
Workshop ............................................................................................................591
Quiz ................................................................................................................591
Exercises ........................................................................................................591
17 Working with Streams 593
Overview of Streams ..........................................................................................593
Encapsulation of Data Flow ..........................................................................594
Understanding Buffering................................................................................594
Streams and Buffers ............................................................................................597
Standard I/O Objects............................................................................................597
Redirection of the Standard Streams ..................................................................598
Input Using
cin....................................................................................................599
Inputting Strings ............................................................................................600
String Problems ..............................................................................................601
The
cin Return Value ....................................................................................603
Other Member Functions of
cin..........................................................................604
Single Character Input....................................................................................604
Getting Strings from Standard Input ..............................................................607
Using
cin.ignore() ......................................................................................610
Peeking at and Returning Characters:
peek() and putback() ......................611
Outputting with
cout ..........................................................................................613
Flushing the Output........................................................................................613
Functions for Doing Output ..........................................................................613
Manipulators, Flags, and Formatting Instructions ........................................615
Streams Versus the
printf() Function................................................................620
File Input and Output ..........................................................................................623
Using the
ofstream..............................................................................................624
Condition States..............................................................................................624
Opening Files for Input and Output ..............................................................624
Changing the Default Behavior of
ofstream on Open ..................................626
Binary Versus Text Files ......................................................................................629
Command-line Processing ..................................................................................631
Summary..............................................................................................................634
Q&A ....................................................................................................................635
Workshop ............................................................................................................636
Quiz ................................................................................................................636
Exercises ........................................................................................................636
Contents xv
00 0672327112_fm.qxd 11/19/04 12:52 PM Page xv
18 Creating and Using Namespaces 637
Getting Started ....................................................................................................637
Resolving Functions and Classes by Name ........................................................638
Visibility of Variables ....................................................................................640
Linkage ..........................................................................................................641
Static Global Variables ..................................................................................642
Creating a Namespace ........................................................................................643
Declaring and Defining Types........................................................................644
Defining Functions Outside a Namespace ....................................................645
Adding New Members ..................................................................................645
Nesting Namespaces ......................................................................................646
Using a Namespace..............................................................................................646
The
using Keyword ............................................................................................648
The
using Directive........................................................................................648
The
using Declaration....................................................................................650
The Namespace Alias ..........................................................................................652
The Unnamed Namespace ..................................................................................652
The Standard Namespace
std..............................................................................654
Summary..............................................................................................................655
Q&A ....................................................................................................................656
Workshop ............................................................................................................656
Quiz ................................................................................................................656
Exercises ........................................................................................................657
19 Templates 659
What Are Templates? ..........................................................................................659
Building a Template Definition ..........................................................................661
Using the Name ..............................................................................................664
Implementing the Template............................................................................665
Passing Instantiated Template Objects to Functions ..........................................669
Templates and Friends ........................................................................................670
Nontemplate Friend Classes and Functions ..................................................670
General Template Friend Class or Function ..................................................674
Using Template Items ..........................................................................................678
Using Specialized Functions ..........................................................................683
Static Members and Templates ......................................................................689
The Standard Template Library ..........................................................................693
Using Containers ............................................................................................693
Understanding Sequence Containers..............................................................694
Understanding Associative Containers ..........................................................704
Working with the Algorithm Classes ............................................................708
Summary..............................................................................................................711
xvi Sams Teach Yourself C++ in 21 Days, Fifth Edition
00 0672327112_fm.qxd 11/19/04 12:52 PM Page xvi
Q&A ....................................................................................................................712
Workshop ............................................................................................................713
Quiz ................................................................................................................713
Exercises ........................................................................................................713
20 Handling Errors and Exceptions 715
Bugs, Errors, Mistakes, and Code Rot ................................................................716
Exceptional Circumstances ............................................................................717
The Idea Behind Exceptions................................................................................718
The Parts of Exception Handling ..................................................................719
Causing Your Own Exceptions ......................................................................722
Creating an Exception Class ..........................................................................724
Placing
try Blocks and catch Blocks ................................................................728
How Catching Exceptions Work..........................................................................728
Using More Than One
catch Specification ..................................................729
Exception Hierarchies ....................................................................................732
Data in Exceptions and Naming Exception Objects ..........................................735
Exceptions and Templates ..................................................................................742
Exceptions Without Errors ..................................................................................745
A Word About Code Rot......................................................................................746
Bugs and Debugging............................................................................................746
Breakpoints ....................................................................................................747
Watch Points ..................................................................................................747
Examining Memory........................................................................................747
Assembler ......................................................................................................747
Summary..............................................................................................................748
Q&A ....................................................................................................................748
Workshop ............................................................................................................749
Quiz ................................................................................................................749
Exercises ........................................................................................................750
21 What’s Next 751
The Preprocessor and the Compiler ....................................................................752
The
#define Preprocessor Directive....................................................................752
Using
#define for Constants..........................................................................753
Using
#define for Tests ................................................................................753
The
#else Precompiler Command ................................................................754
Inclusion and Inclusion Guards ..........................................................................755
Macro Functions ..................................................................................................756
Why All the Parentheses? ..............................................................................757
String Manipulation ............................................................................................759
Stringizing ......................................................................................................759
Concatenation ................................................................................................759
Contents xvii
00 0672327112_fm.qxd 11/19/04 12:52 PM Page xvii
Predefined Macros ..............................................................................................760
The
assert() Macro............................................................................................761
Debugging with
assert() ..............................................................................762
Using
assert() Versus Exceptions ................................................................763
Side Effects ....................................................................................................763
Class Invariants ..............................................................................................764
Printing Interim Values ..................................................................................769
Inline Functions ..................................................................................................771
Bit Twiddling ......................................................................................................773
Operator AND ................................................................................................773
Operator OR ..................................................................................................774
Operator Exclusive OR ..................................................................................774
The Complement Operator ............................................................................774
Setting Bits ....................................................................................................774
Clearing Bits ..................................................................................................774
Flipping Bits ..................................................................................................775
Bit Fields ........................................................................................................775
Programming Style ..............................................................................................779
Indenting ........................................................................................................779
Braces ............................................................................................................779
Long Lines and Function Length ..................................................................780
Structuring
switch Statements ......................................................................780
Program Text ..................................................................................................780
Naming Identifiers..........................................................................................781
Spelling and Capitalization of Names............................................................782
Comments ......................................................................................................782
Setting Up Access ..........................................................................................783
Class Definitions ............................................................................................783
include Files ..................................................................................................784
Using
assert() ..............................................................................................784
Making Items Constant with
const................................................................784
Next Steps in Your C++ Development ................................................................784
Where to Get Help and Advice ......................................................................785
Related C++ Topics: Managed C++, C#, and Microsoft’s .NET ..................785
Staying in Touch ............................................................................................786
Summary..............................................................................................................786
Q&A ....................................................................................................................787
Workshop ............................................................................................................788
Quiz ................................................................................................................788
Exercises ........................................................................................................789
Week 3 In Review 791
xviii Sams Teach Yourself C++ in 21 Days, Fifth Edition
00 0672327112_fm.qxd 11/19/04 12:52 PM Page xviii
A Working with Numbers: Binary and Hexadecimal 807
Using Other Bases ..............................................................................................808
Converting to Different Bases ............................................................................809
Binary ............................................................................................................810
Why Base 2? ..................................................................................................811
Bits, Bytes, and Nybbles ................................................................................812
What’s a KB?..................................................................................................812
Binary Numbers..............................................................................................812
Hexadecimal ........................................................................................................813
B C++ Keywords 817
C Operator Precedence 819
D Answers 821
Day 1....................................................................................................................821
Quiz ................................................................................................................821
Exercises ........................................................................................................822
Day 2....................................................................................................................822
Quiz ................................................................................................................822
Exercises ........................................................................................................823
Day 3....................................................................................................................824
Quiz ................................................................................................................824
Exercises ........................................................................................................825
Day 4....................................................................................................................825
Quiz ................................................................................................................825
Exercises ........................................................................................................826
Day 5....................................................................................................................826
Quiz ................................................................................................................826
Exercises ........................................................................................................827
Day 6....................................................................................................................829
Quiz ................................................................................................................829
Exercises ........................................................................................................829
Day 7....................................................................................................................832
Quiz ................................................................................................................832
Exercises ........................................................................................................832
Day 8....................................................................................................................833
Quiz ................................................................................................................833
Exercises ........................................................................................................834
Day 9....................................................................................................................835
Quiz ................................................................................................................835
Exercises ........................................................................................................835
Contents xix
00 0672327112_fm.qxd 11/19/04 12:52 PM Page xix
剩余936页未读,继续阅读
点击了解资源详情
点击了解资源详情
点击了解资源详情
2010-06-14 上传
2009-05-01 上传
2018-11-30 上传
2007-06-03 上传
2015-04-01 上传
2010-03-07 上传
nov29
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 俄罗斯RTSD数据集实现交通标志实时检测
- 易语言开发的文件批量改名工具使用Ex_Dui美化界面
- 爱心援助动态网页教程:前端开发实战指南
- 复旦微电子数字电路课件4章同步时序电路详解
- Dylan Manley的编程投资组合登录页面设计介绍
- Python实现H3K4me3与H3K27ac表观遗传标记域长度分析
- 易语言开源播放器项目:简易界面与强大的音频支持
- 介绍rxtx2.2全系统环境下的Java版本使用
- ZStack-CC2530 半开源协议栈使用与安装指南
- 易语言实现的八斗平台与淘宝评论采集软件开发
- Christiano响应式网站项目设计与技术特点
- QT图形框架中QGraphicRectItem的插入与缩放技术
- 组合逻辑电路深入解析与习题教程
- Vue+ECharts实现中国地图3D展示与交互功能
- MiSTer_MAME_SCRIPTS:自动下载MAME与HBMAME脚本指南
- 前端技术精髓:构建响应式盆栽展示网站
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功