没有合适的资源?快使用搜索试试~ 我知道了~
Thinking in C++ Second Edition
5星 · 超过95%的资源 需积分: 10 8 下载量 198 浏览量
2012-11-13
23:36:23
上传
评论
收藏 4.06MB PDF 举报
温馨提示
试读
1128页
Thinking in C++ Second Edition是英文版的,有目录的
资源推荐
资源详情
资源评论
Thinking
In
C++
Bruce Eckel
President, MindView Inc.
Prentice Hall PTR
Upper Saddle River, New Jersey 07458
http://www.phptr.com
Publisher:
Alan Apt
Production Editor:
Mona Pompilli
Development Editor:
Sondra Chavez
Book Design, Cover Design and Cover Photo:
Daniel Will-Harris, daniel@will-harris.com
Copy Editor:
Shirley Michaels
Production Coordinator:
Lori Bulwin
Editorial Assistant:
Shirley McGuire
© 1999 by Bruce Eckel, MindView, Inc.
Published by Prentice Hall Inc.
A Paramount Communications Company
Englewood Cliffs, New Jersey 07632
The information in this book is distributed on an “as is” basis, without warranty. While every precaution
has been taken in the preparation of this book, neither the author nor the publisher shall have any
liability to any person or entitle with respect to any liability, loss or damage caused or alleged to be
caused directly or indirectly by instructions contained in this book or by the computer software or
hardware products described herein.
All rights reserved. No part of this book may be reproduced in any form or by any electronic or
mechanical means including information storage and retrieval systems without permission in writing
from the publisher or author, except by a reviewer who may quote brief passages in a review. Any of the
names used in the examples and text of this book are fictional; any relationship to persons living or dead
or to fictional characters in other works is purely coincidental.
Printed in the United States of America
10 9 8 7 6 5 4 3 2 1
ISBN 0-13-917709-4
Prentice-Hall International (UK) Limited,
London
Prentice-Hall of Australia Pty. Limited,
Sydney
Prentice-Hall Canada, Inc.,
Toronto
Prentice-Hall Hisapnoamericana, S.A.,
Mexico
Prentice-Hall of India Private Limited,
New Delhi
Prentice-Hall of Japan, Inc.,
Tokyo
Simon & Schuster Asia Pte. Ltd.,
Singapore
Editora Prentice-Hall do Brasil, Ltda.,
Rio de Janeiro
dedication
to the scholar, the healer, and the muse
What’s inside...
Thinking in C++ 2
nd
edition VERSION
TICA17 .............................................. 1
Preface 17
Prerequisites...............................17
Thinking in C....................................17
Learning C++.............................18
Goals ..........................................19
Chapters......................................20
Exercises ....................................23
Source code................................24
Coding standards.............................. 25
Language standards....................26
Language support.............................26
Seminars & CD Roms................26
Errors..........................................27
Acknowledgements ....................27
1: Introduction to objects 29
The progress of abstraction ........29
An object has an interface ..........31
The hidden implementation........33
Reusing the implementation......34
Inheritance: reusing the interface35
Is-a vs. is-like-a relationships ........... 39
Interchangeable objects with
polymorphism ............................40
Creating and destroying objects .43
Exception handling: dealing with
errors ..........................................44
Analysis and design....................45
Phase 0: Make a plan........................ 47
Phase 1: What are we making?......... 48
Phase 2: How will we build it?......... 50
Phase 3: Build it ............................... 53
Phase 4: Iteration..............................53
Plans pay off..................................... 55
Why C++ succeeds.....................55
A better C.........................................56
You’re already on the learning curve 56
Efficiency .........................................56
Systems are easier to express and
understand ........................................57
Maximal leverage with libraries ....... 57
Source-code reuse with templates.....57
Error handling...................................57
Programming in the large .................58
Strategies for transition..............58
Guidelines.........................................58
Management obstacles......................60
Summary....................................61
2: Making & using objects 63
The process of language translation63
Interpreters........................................ 64
Compilers.........................................64
The compilation process................... 65
Tools for separate compilation... 66
Declarations vs. definitions...............67
Linking.............................................71
Using libraries ..................................72
Your first C++ program.............. 73
Using the iostreams class.................. 73
Namespaces...................................... 74
Fundamentals of program structure ..75
"Hello, world!".................................76
Running the compiler .......................77
More about iostreams................. 77
Character array concatenation...........78
Reading input ...................................78
Simple file manipulation...................79
Introducing
string
s ....................80
Reading and writing files ........... 82
Introducing
vector
.....................84
Summary....................................87
Exercises.................................... 88
3: The C in C++ 91
Creating functions......................91
Using the C function library ............. 94
Creating your own libraries with the
librarian............................................94
Controlling execution.................95
True and false................................... 95
if-else
................................................ 95
while
................................................. 96
do-while
........................................... 97
for
..................................................... 98
The
break
and
continue
Keywords..99
switch
............................................. 100
Recursion........................................ 102
Introduction to operators..........102
Precedence...................................... 103
Auto increment and decrement....... 103
Introduction to data types.........104
Basic built-in types......................... 104
bool
,
true
, &
false
.......................... 105
Specifiers........................................ 106
Introduction to Pointers .................. 108
Modifying the outside object .......... 112
Introduction to C++ references....... 114
Pointers and references as modifiers115
Scoping.....................................117
Defining variables on the fly .......... 118
Specifying storage allocation ...120
Global variables..............................120
Local variables ............................... 121
static
............................................... 121
extern
............................................. 123
Constants........................................ 124
volatile
........................................... 125
Operators and their use.............126
Assignment..................................... 126
Mathematical operators .................. 126
Relational operators........................ 128
Logical operators............................ 128
Bitwise operators............................129
Shift operators ................................ 129
Unary operators.............................. 132
The ternary operator ....................... 133
The comma operator....................... 133
Common pitfalls when using operators134
Casting operators............................ 134
sizeof
– an operator by itself........... 135
The
asm
keyword........................... 135
Explicit operators............................135
Composite type creation...........136
Aliasing names with
typedef
.......... 136
Combining variables with
struct
.... 137
Clarifying programs with
enum
..... 140
Saving memory with
union
............ 141
Arrays............................................. 142
Debugging hints .......................150
Debugging flags .............................151
Turning variables and expressions into
strings.............................................152
The C
assert( )
macro.....................153
Make: an essential tool for separate
compilation ..............................154
Make activities................................155
Makefile
s in this book.................... 157
An example
makefile
.....................158
Summary..................................160
Exercises.................................. 160
4: Data abstraction 163
A tiny C-like library................. 164
Dynamic storage allocation ............167
Bad guesses ....................................170
What's wrong?..........................171
The basic object ....................... 172
What's an object? ..................... 178
Abstract data typing................. 179
Object details ...........................179
Header file etiquette.................181
Importance of header files..............181
The multiple-declaration problem...183
The preprocessor directives
#define
,
#ifdef
and
#endif
............................183
A standard for header files.............. 184
Namespaces in headers...................185
Using headers in projects................ 185
Nested structures......................186
Global scope resolution ..................189
Summary..................................190
Exercises.................................. 190
5: Hiding the implementation
195
Setting limits............................195
C++ access control...................196
protected
........................................198
Friends .....................................198
Nested friends................................. 200
Is it pure?........................................ 203
Object layout............................ 203
The class .................................. 204
Modifying
Stash
to use access control206
Modifying
Stack
to use access control207
Handle classes.......................... 208
Hiding the implementation.............208
Reducing recompilation.................. 208
Summary..................................211
Exercises.................................. 211
剩余1127页未读,继续阅读
资源评论
- Sput_2013-09-14非常好的一本书,最喜欢英文版
- tbcxs2013-02-26不错的书,也挺清晰的。谢谢分享
LawlietXXL_keepgoing
- 粉丝: 0
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- note test a bc d e f g h
- MERGE.csv.zip
- 15白落梅:你是锦瑟我为流年:三毛的万水千山-3491776.mobi
- 微信小程序源码 实现 城市切换 demo 根据城市首字母排序城市 选择城市
- 12因为懂得 所以慈悲-张爱玲的倾城往事 (白落梅经典散文系列)-3321089.mobi
- 基于 C# 实现的串口温度监控软件
- 基于STM32F103RBT6单片机+SIM868自动收货机主控板硬件(原理图+PCB)工程文件.zip
- 微信小程序源码 车源宝 二手车交易平台 源码下载
- 专注于在线教育领域,打造更好的网课系统,网校系统,知识付费系统
- ADM487EARZ-REEL7 产品规格书pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功