Sciweavers


Book

C++: A Dialog

15 years 1 days ago
C++: A Dialog
"Assuming that you want to learn C++, why should you read this book rather than any of dozens of other introductory C++ books? One difference between this book and other introductory books is that many of them still don't use the C++ standard library, a very important part of the C++ language definition. We'll make use of some of the features of the standard library in this book, to get you started on learning this large and complex part of the C++ language. However, we certainly won't cover it in its entirety; that would require much more room that we can devote to it here. In fact, many books can be and have been written about the standard library alone, although I don't know of any that would be suitable for novices to programming."
Steve Heller
Added 30 Mar 2009
Updated 30 Mar 2009
Authors Steve Heller
CHAPTER 1      Introduction to Programming 1
Baby Steps 7
 
CHAPTER 2      Hardware Fundamentals 11
Objectives of This Chapter 13
Inside the Box 14
The Binary Number System 32
Exercises 48
Using the 16-bit Register Names 48
Review 63
Conclusion 64
Answers to Exercises 64
 
CHAPTER 3      Basics of Programming 67
Objectives of This Chapter 68
Rapid and Accurate Calculation 69
The Compiler 72
How the CPU Stores and Manipulates Data in Memory 77
The Layout of Data in Memory 80
Exercises, First Set 82
The char and string Types 96
using, namespace, and std 98
int main() 100
Exercises, Second Set 109
Input and Output 110
Changing the Course of Execution 112
The while Loop 115
Exercises, Third Set 117
Our First Slightly Realistic Program 118
Exercises, Fourth Set 128
Review 129
Conclusion 132
Answers to Exercises 133
 
CHAPTER 4      More Basics 149
Algorithmic Thinking 150
Handling Any Number of Prizes 159
Index Variables 169
The Selection Sort 178
Program Failure 200
Review 207
Exercises 209
Conclusion 211
Answers to Exercises 212
 
CHAPTER 5      Functional Literacy 219
Objectives of This Chapter 223
Modules vs. Functions 223
Using a Function 239
Software Is a Virtual Computer 247
Scope of Variables 267
The Disadvantages of Global Variables 282
More on Using the Stack 285
Review 287
Exercises 290
Conclusion 291
Answers to Exercises 291
 
CHAPTER 6      Taking Inventory 295
Objectives of This Chapter 298
User-defined Data Types 299
The StockItem class 305
More Definitions 308
Concrete Data Types 309
The class Scope 327
More about the StockItem class Interface 333
Working around the Standard Library 348
Reference Arguments 350
Checking Inventory for a Misplaced Item 391
Review 392
Exercises 401
Conclusion 402
Answers to Exercises 402
 
CHAPTER 7      Creating a Homegrown string class 405
C String Literals vs. strings 406
Dynamic Memory Allocation via new and delete 417
Constructing a string from a C String 424
Assignment Operator Issues 438
Solving the Assignment Operator Problem 441
The const Modifier for Reference Arguments 444
Calling operator= 448
Review 466
Exercises 467
Conclusion 469
Answers to Exercises 470
 
CHAPTER 8      Finishing Our homegrown string class 473
The string Copy Constructor 483
More about the private Access Specifier 500
First Review 506
Adding Further Facilities to our string class 510
Initialization vs. Assignment 542
Second Review 549
Exercises 551
Conclusion 553
Answers to Exercises 554
 
CHAPTER 9      Inheritance 563
Objectives of This Chapter 565
Taking Inventory 574
Adding ReorderItems to the Inventory class 575
Adding Expiration Dates 581
The protected Access Specifier 596
static Member Functions 616
The stream classes 621
More about stringstream 624
Review 651
Exercises 654
Conclusion 656
 
CHAPTER 10    Polymorphism 657
Objectives of This Chapter 659
Introduction to Polymorphism 659
Exercises, First Set 693
Polymorphic Objects 694
More Definitions 694
Why We Need Polymorphic Objects 695
Implementing Safe Polymorphism 700
Reimplementing the Standard Member Functions for the New Version of StockItem 715
Avoiding an Infinite Regress During Construction 720
Reference Counting 723
Sharing a Worker Object 724
Why We Need m_Count in StockItem 743
Review 746
Exercises, Second Set 751
Conclusion 752
 
CHAPTER 11    The Home Inventory Project 753
Objectives of This Chapter 754
Data Items for the Home Inventory Project 755
The Manager/Worker Idiom Again 758
Hiding Unnecessary Information from the class User 763
Saving the Number of the Elements in the File 793
Creating a Data File Programmatically 797
Adding the Ability to Edit a Record 814
The New Member Functions of HomeItemMusic 839
Review 846
Exercises 853
Conclusion 854
 
CHAPTER 12    More on the Home Inventory Project 855
Objectives of This Chapter 857
Extending the Functionality of strings 857
How to Implement Our New string Functionality 858
The Include Guard 863
Lessons of the xstring class Implementation 878
Case-Insensitive Searching 880
Searching for an Item by a Substring 888
Putting It All Together 895
How Software Development Really Works 906
Review 907
Conclusion 910
 
CHAPTER 13    Analyzing the Home Inventory Project 911
Objectives of This Chapter 912
The Final Version of the Home Inventory Program 913
Using a namespace to Group Utility Functions 925
The Functions of the HomeUtility namespace 930
Checking the Inventory 955
Finishing up the HomeItem class 974
Are We Having Fun Yet? 983
Review 983
Exercises 988
Conclusion 989
APPENDIX A     Tying up Loose Ends 991
Comments (0)