<b>Bestselling Programming Tutorial and Reference Completely Rewritten for the New C++11 Standard</b>Fully updated and recast for the newly released C++11 standard, this authoritative and comprehensive introduction to C++ will help you to learn the language fast, and to use it in modern, highly effe
C++ Primer Plus, Fifth Edition
β Scribed by Prata, Stephen
- Publisher
- Sams
- Year
- 2004
- Tongue
- English
- Leaves
- 1225
- Series
- Eiji Yamane's Library
- Edition
- 5th edition
- Category
- Library
No coin nor oath required. For personal study only.
β¦ Synopsis
Covers the language enhancements, the Standard Template Library and ways to streamline object-oriented programming with C++. This guide also illustrates how to handle input and output, make programs perform repetitive tasks, manipulate data, hide information, use functions and build flexible, easily modifiable programs.
β¦ Table of Contents
Cover......Page 1
TABLE OF CONTENTS......Page 6
INTRODUCTION......Page 24
Learning C++: What Lies Before You......Page 34
The Origins of C++: A Little History......Page 35
C Programming Philosophy......Page 36
The C++ Shift: Object-Oriented Programming......Page 37
C++ and Generic Programming......Page 38
The Genesis of C++......Page 39
Portability and Standards......Page 40
The Mechanics of Creating a Program......Page 42
Creating the Source Code File......Page 43
Compilation and Linking......Page 45
Summary......Page 50
C++ Initiation......Page 52
The main() Function......Page 54
C++ Comments......Page 57
The C++ Preprocessor and the iostream File......Page 58
Header Filenames......Page 59
Namespaces......Page 60
C++ Output with cout......Page 61
C++ Source Code Formatting......Page 64
Declaration Statements and Variables......Page 66
Assignment Statements......Page 68
A New Trick for cout......Page 69
Using cin......Page 70
cin and cout: A Touch of Class......Page 71
Using a Function That Has a Return Value......Page 73
Function Variations......Page 77
User-Defined Functions......Page 78
Using a User-Defined Function That Has a Return Value......Page 81
Placing the using Directive in Multifunction Programs......Page 83
Summary......Page 85
Review Questions......Page 86
Programming Exercises......Page 87
CHAPTER 3: Dealing with Data......Page 88
Names for Variables......Page 89
The short, int, and long Integer Types......Page 91
Unsigned Types......Page 96
Choosing an Integer Type......Page 98
Integer Constants......Page 99
How C++ Decides What Type a Constant Is......Page 101
The char Type: Characters and Small Integers......Page 102
The bool Type......Page 110
The const Qualifier......Page 111
Writing Floating-Point Numbers......Page 112
Floating-Point Types......Page 114
Floating-Point Constants......Page 116
Advantages and Disadvantages of Floating-Point Numbers......Page 117
C++ Arithmetic Operators......Page 118
Order of Operation: Operator Precedence and Associativity......Page 119
Division Diversions......Page 120
The Modulus Operator......Page 122
Type Conversions......Page 123
Summary......Page 128
Review Questions......Page 129
Programming Exercises......Page 130
CHAPTER 4: Compound Types......Page 132
Introducing Arrays......Page 133
Program Notes......Page 135
Initialization Rules for Arrays......Page 136
Strings......Page 137
Using Strings in an Array......Page 139
Adventures in String Input......Page 141
Reading String Input a Line at a Time......Page 142
Mixing String and Numeric Input......Page 147
Introducing the string Class......Page 148
Assignment, Concatenation, and Appending......Page 149
More string Class Operations......Page 150
More on string Class I/O......Page 152
Introducing Structures......Page 154
Using a Structure in a Program......Page 156
Can a Structure Use a string Class Member?......Page 158
Other Structure Properties......Page 159
Arrays of Structures......Page 160
Unions......Page 162
Enumerations......Page 164
Setting Enumerator Values......Page 165
Value Ranges for Enumerations......Page 166
Pointers and the Free Store......Page 167
Declaring and Initializing Pointers......Page 170
Pointer Danger......Page 172
Allocating Memory with new......Page 173
Freeing Memory with delete......Page 175
Using new to Create Dynamic Arrays......Page 176
Pointers, Arrays, and Pointer Arithmetic......Page 179
Program Notes......Page 180
Pointers and Strings......Page 185
Using new to Create Dynamic Structures......Page 189
Automatic Storage, Static Storage, and Dynamic Storage......Page 193
Summary......Page 195
Review Questions......Page 196
Programming Exercises......Page 197
CHAPTER 5: Loops and Relational Expressions......Page 200
Introducing for Loops......Page 201
for Loop Parts......Page 202
Back to the for Loop......Page 208
Changing the Step Size......Page 210
Inside Strings with the for Loop......Page 211
The Increment (++) and Decrement (--) Operators......Page 212
Side Effects and Sequence Points......Page 213
The Increment/Decrement Operators and Pointers......Page 214
Combination Assignment Operators......Page 215
Compound Statements, or Blocks......Page 216
The Comma Operator (or More Syntax Tricks)......Page 218
Relational Expressions......Page 221
A Mistake Youβll Probably Make......Page 222
Comparing C-Style Strings......Page 224
Comparing string Class Strings......Page 227
The while Loop......Page 228
for Versus while......Page 230
Just a MomentβBuilding a Time-Delay Loop......Page 232
The do while Loop......Page 234
Loops and Text Input......Page 236
Using Unadorned cin for Input......Page 237
cin.get(char) to the Rescue......Page 238
Which cin.get()?......Page 239
The End-of-File Condition......Page 240
Yet Another Version of cin.get()......Page 243
Nested Loops and Two-Dimensional Arrays......Page 246
Initializing a Two-Dimensional Array......Page 248
Summary......Page 250
Review Questions......Page 251
Programming Exercises......Page 252
The if Statement......Page 254
The if else Statement......Page 256
Formatting if else Statements......Page 258
The if else if else Construction......Page 259
The Logical OR Operator: ||......Page 261
The Logical AND Operator: &&......Page 262
The Logical NOT Operator: !......Page 267
Logical Operator Facts......Page 269
The cctype Library of Character Functions......Page 270
The ?: Operator......Page 273
The switch Statement......Page 274
Using Enumerators as Labels......Page 278
The break and continue Statements......Page 279
Program Notes......Page 281
Number-Reading Loops......Page 282
Simple File Input/Output......Page 285
Text I/O and Text Files......Page 286
Writing to a Text File......Page 287
Reading from a Text File......Page 291
Summary......Page 296
Review Questions......Page 297
Programming Exercises......Page 299
CHAPTER 7: Functions: C++βs Programming Modules......Page 302
Function Review......Page 303
Defining a Function......Page 304
Prototyping and Calling a Function......Page 306
Function Arguments and Passing by Value......Page 309
Multiple Arguments......Page 311
Another Two-Argument Function......Page 313
Functions and Arrays......Page 316
How Pointers Enable Array-Processing Functions......Page 317
The Implications of Using Arrays as Arguments......Page 318
More Array Function Examples......Page 320
Functions Using Array Ranges......Page 326
Pointers and const......Page 328
Functions and Two-Dimensional Arrays......Page 331
Functions and C-Style Strings......Page 332
Functions with C-Style String Arguments......Page 333
Functions That Return C-Style Strings......Page 335
Functions and Structures......Page 336
Passing and Returning Structures......Page 337
Another Example of Using Functions with Structures......Page 339
Passing Structure Addresses......Page 343
Functions and string Class Objects......Page 345
Recursion with a Single Recursive Call......Page 347
Recursion with Multiple Recursive Calls......Page 349
Pointers to Functions......Page 350
Function Pointer Basics......Page 351
A Function Pointer Example......Page 353
Summary......Page 355
Review Questions......Page 356
Programming Exercises......Page 357
C++ Inline Functions......Page 360
Reference Variables......Page 363
Creating a Reference Variable......Page 364
References as Function Parameters......Page 367
Reference Properties and Oddities......Page 370
Using References with a Structure......Page 374
Using References with a Class Object......Page 378
Another Object Lesson: Objects, Inheritance, and References......Page 381
When to Use Reference Arguments......Page 384
Default Arguments......Page 385
Program Notes......Page 387
Function Overloading......Page 388
An Overloading Example......Page 390
Function Templates......Page 393
Overloaded Templates......Page 397
Explicit Specializations......Page 399
Instantiations and Specializations......Page 403
Which Function Version Does the Compiler Pick?......Page 405
Summary......Page 411
Review Questions......Page 412
Programming Exercises......Page 413
Separate Compilation......Page 416
Scope and Linkage......Page 422
Automatic Storage Duration......Page 423
Static Duration Variables......Page 429
Specifiers and Qualifiers......Page 438
Functions and Linkage......Page 441
Storage Schemes and Dynamic Allocation......Page 442
The Placement new Operator......Page 443
Program Notes......Page 446
Traditional C++ Namespaces......Page 447
New Namespace Features......Page 449
A Namespace Example......Page 456
Summary......Page 460
Review Questions......Page 461
Programming Exercises......Page 464
CHAPTER 10: Objects and Classes......Page 468
Procedural and Object-Oriented Programming......Page 469
What Is a Type?......Page 470
Classes in C++......Page 471
Implementing Class Member Functions......Page 476
Using Classes......Page 481
Reviewing Our Story to Date......Page 485
Class Constructors and Destructors......Page 486
Declaring and Defining Constructors......Page 487
Using Constructors......Page 488
Default Constructors......Page 489
Destructors......Page 490
Improving the Stock Class......Page 491
Constructors and Destructors in Review......Page 498
Knowing Your Objects: The this Pointer......Page 500
An Array of Objects......Page 506
The Interface and Implementation Revisited......Page 509
Class Scope......Page 510
Class Scope Constants......Page 511
Abstract Data Types......Page 512
Summary......Page 518
Programming Exercises......Page 519
CHAPTER 11: Working with Classes......Page 524
Operator Overloading......Page 525
Time on Our Hands: Developing an Operator Overloading Example......Page 526
Adding an Addition Operator......Page 529
Overloading Restrictions......Page 533
More Overloaded Operators......Page 535
Introducing Friends......Page 538
Creating Friends......Page 539
A Common Kind of Friend: Overloading the << Operator......Page 541
Overloaded Operators: Member Versus Nonmember Functions......Page 547
More Overloading: A Vector Class......Page 548
Using a State Member......Page 556
Overloading Arithmetic Operators for the Vector Class......Page 558
An Implementation Comment......Page 560
Taking the Vector Class on a Random Walk......Page 561
Automatic Conversions and Type Casts for Classes......Page 564
Conversion Functions......Page 570
Conversions and Friends......Page 576
Summary......Page 579
Programming Exercises......Page 581
CHAPTER 12: Classes and Dynamic Memory Allocation......Page 584
A Review Example and Static Class Members......Page 585
Implicit Member Functions......Page 594
The New, Improved String Class......Page 602
Things to Remember When Using new in Constructors......Page 613
Observations About Returning Objects......Page 616
Using Pointers to Objects......Page 619
Reviewing Techniques......Page 629
A Queue Simulation......Page 630
A Queue Class......Page 631
The Customer Class......Page 641
The Simulation......Page 644
Summary......Page 649
Review Questions......Page 650
Programming Exercises......Page 652
CHAPTER 13: Class Inheritance......Page 656
Beginning with a Simple Base Class......Page 657
Deriving a Class......Page 659
Constructors: Access Considerations......Page 661
Using a Derived Class......Page 664
Special Relationships Between Derived and Base Classes......Page 666
Inheritance: An Is-a Relationship......Page 668
Polymorphic Public Inheritance......Page 670
Developing the Brass and BrassPlus Classes......Page 671
Pointer and Reference Type Compatibility......Page 683
Virtual Member Functions and Dynamic Binding......Page 685
Things to Know About Virtual Methods......Page 687
Access Control: protected......Page 691
Abstract Base Classes......Page 693
Applying the ABC Concept......Page 695
Case 1: Derived Class Doesnβt Use new......Page 700
Case 2: Derived Class Does Use new......Page 702
An Inheritance Example with Dynamic Memory Allocation and Friends......Page 704
Class Design Review......Page 708
Member Functions That the Compiler Generates for You......Page 709
Other Class Method Considerations......Page 710
Public Inheritance Considerations......Page 714
Class Function Summary......Page 718
Summary......Page 719
Review Questions......Page 720
Programming Exercises......Page 721
Classes with Object Members......Page 724
The valarray Class: A Quick Look......Page 725
The Student Class Design......Page 726
The Student Class Example......Page 728
Private Inheritance......Page 735
The Student Class Example (New Version)......Page 736
Multiple Inheritance......Page 746
How Many Workers?......Page 751
Which Method?......Page 755
MI Synopsis......Page 766
Defining a Class Template......Page 767
Using a Template Class......Page 771
A Closer Look at the Template Class......Page 773
An Array Template Example and Non-Type Arguments......Page 779
Template Versatility......Page 781
Template Specializations......Page 785
Member Templates......Page 788
Templates as Parameters......Page 791
Template Classes and Friends......Page 793
Summary......Page 800
Review Questions......Page 802
Programming Exercises......Page 804
Friends......Page 810
Friend Classes......Page 811
Friend Member Functions......Page 816
Other Friendly Relationships......Page 819
Nested Classes......Page 821
Nested Classes and Access......Page 823
Nesting in a Template......Page 824
Calling abort()......Page 828
Returning an Error Code......Page 830
The Exception Mechanism......Page 831
Using Objects as Exceptions......Page 835
Unwinding the Stack......Page 839
More Exception Features......Page 845
The exception Class......Page 847
Exceptions, Classes, and Inheritance......Page 852
When Exceptions Go Astray......Page 857
Exception Cautions......Page 860
RTTI......Page 862
How Does RTTI Work?......Page 863
Type Cast Operators......Page 871
Summary......Page 875
Review Questions......Page 876
Programming Exercises......Page 877
The string Class......Page 880
Constructing a String......Page 881
string Class Input......Page 885
Working with Strings......Page 887
What Else Does the string Class Offer?......Page 893
The auto_ptr Class......Page 896
Using auto_ptr......Page 897
auto_ptr Considerations......Page 899
The STL......Page 900
The vector Template Class......Page 901
Things to Do to Vectors......Page 903
More Things to Do to Vectors......Page 908
Why Iterators?......Page 913
Kinds of Iterators......Page 917
Iterator Hierarchy......Page 920
Concepts, Refinements, and Models......Page 921
Kinds of Containers......Page 928
Associative Containers......Page 938
Function Objects (aka Functors)......Page 945
Functor Concepts......Page 946
Predefined Functors......Page 949
Adaptable Functors and Function Adapters......Page 951
Algorithms......Page 953
Algorithm Groups......Page 954
General Properties of Algorithms......Page 955
The STL and the string Class......Page 956
Functions Versus Container Methods......Page 957
Using the STL......Page 959
vector and valarray......Page 963
Summary......Page 969
Review Questions......Page 971
Programming Exercises......Page 972
CHAPTER 17: Input, Output, and Files......Page 974
Streams and Buffers......Page 975
Streams, Buffers, and the iostream File......Page 978
Redirection......Page 980
The Overloaded << Operator......Page 981
The Other ostream Methods......Page 984
Flushing the Output Buffer......Page 987
Formatting with cout......Page 988
Input with cin......Page 1006
How cin >> Views Input......Page 1008
Stream States......Page 1010
Other istream Class Methods......Page 1014
Other istream Methods......Page 1022
File Input and Output......Page 1026
Simple File I/O......Page 1027
Stream Checking and is_open()......Page 1030
Command-Line Processing......Page 1031
File Modes......Page 1034
Random Access......Page 1044
Incore Formatting......Page 1053
What Now?......Page 1055
Summary......Page 1056
Review Questions......Page 1057
Programming Exercises......Page 1059
Octal Integers (Base 8)......Page 1064
Hexadecimal Numbers (Base 16)......Page 1065
Binary and Hex......Page 1066
C++ Keywords......Page 1070
C++ Library Reserved Names......Page 1071
APPENDIX C: The ASCII Character Set......Page 1074
APPENDIX D: Operator Precedence......Page 1080
The Shift Operators......Page 1086
The Logical Bitwise Operators......Page 1088
Alternative Representations of Bitwise Operators......Page 1090
A Few Common Bitwise Operator Techniques......Page 1091
Member Dereferencing Operators......Page 1093
APPENDIX F: The string Template Class......Page 1098
Thirteen Types and a Constant......Page 1099
Data Information, Constructors, and Odds and Ends......Page 1100
Constructors That Use Arrays......Page 1102
Copy Constructors......Page 1103
Constructors That Use n Copies of a Character......Page 1104
Memory Miscellany......Page 1105
String Access......Page 1106
The find() Family......Page 1107
The rfind() Family......Page 1108
The find_last_of() Family......Page 1109
The find_last_not_of() Family......Page 1110
Comparison Methods and Functions......Page 1111
Methods for Appending and Adding......Page 1112
More Assignment Methods......Page 1113
Erase Methods......Page 1114
Replacement Methods......Page 1115
Output and Input......Page 1116
Members Common to All Containers......Page 1118
Additional Members for Vectors, Lists, and Deques......Page 1121
Additional Members for Sets and Maps......Page 1124
STL Functions......Page 1125
Nonmodifying Sequence Operations......Page 1126
Mutating Sequence Operations......Page 1130
Sorting and Related Operations......Page 1138
Numeric Operations......Page 1149
Selected Readings......Page 1152
Internet Resources......Page 1154
Use const Instead of #define to Define Constants......Page 1156
Use inline Instead of #define to Define Short Functions......Page 1158
Use Type Casts......Page 1159
Use Namespaces......Page 1160
Use the autoptr Template......Page 1161
Use the STL......Page 1162
Answers to Review Questions for Chapter 2......Page 1164
Answers to Review Questions for Chapter 3......Page 1165
Answers to Review Questions for Chapter 4......Page 1166
Answers to Review Questions for Chapter 5......Page 1167
Answers to Review Questions for Chapter 6......Page 1168
Answers to Review Questions for Chapter 7......Page 1170
Answers to Review Questions for Chapter 8......Page 1171
Answers to Review Questions for Chapter 9......Page 1173
Answers to Review Questions for Chapter 10......Page 1174
Answers to Review Questions for Chapter 11......Page 1177
Answers to Review Questions for Chapter 12......Page 1178
Answers to Review Questions for Chapter 13......Page 1180
Answers to Review Questions for Chapter 14......Page 1182
Answers to Review Questions for Chapter 15......Page 1183
Answers to Review Questions for Chapter 16......Page 1184
Answers to Review Questions for Chapter 17......Page 1185
A......Page 1188
B......Page 1191
C......Page 1192
D......Page 1199
E......Page 1200
F......Page 1201
I......Page 1204
L......Page 1207
M......Page 1208
N......Page 1210
O......Page 1211
P......Page 1213
R......Page 1215
S......Page 1216
T......Page 1222
V......Page 1223
X-Z......Page 1225
β¦ Subjects
Computer Science;Programming;Science;Reference;Computers;Nonfiction;Technical;Technology;Education;Coding;Software
π SIMILAR VOLUMES
C Primer Plus is a conversational-style book aimed at those new to C programming. A friendly and easy-to-use self-study guide, this book will be appropriate for serious students of programming, as well as developers proficient in other languages with a desire to better understand the fundamentals of
C Primer Plus is a carefully tested, well-crafted, and complete tutorial on a subject core to programmers and developers. This computer science classic teaches principles of programming, including structured code and top-down design. Author and educator Stephen Prata has created an introduction to
<p>C++ Primer Plus, Sixth Edition New C++11 Coverage C++ Primer Plus is a carefully crafted, complete tutorial on one of the most significant and widely used programming languages today. An accessible and easy-to-use self-study guide, this book is appropriate for both serious students of programming
I have gone through a little over half of this book so far, and I feel I need to write a review based on a few things I have seen. 1. The book is very well organized. It starts from absolute basics, and builds on everything from there. This makes going from chapter to chapter very easy. 2. Some o
C# Primer Plus teaches the C# programming language and relevant parts of the .NET platform from the ground up, walking you through the basics of object-oriented programming, important programming techniques and problem solving while providing a thorough coverage of C#'s essential elements - such as