TOC PREV NEXT INDEX


I've just released a deduplicating backup product for
VMWare Workstation and Server.
Do you need to reduce the storage needed to maintain multiple backups?
Or do you need multiple snapshots on VMWare Server?
If you have either of these needs, just click
here to get started for only $29 (limited time offer ends July 31st, 2011)!

C++: A Dialog


List of Figures
Chapter 1: Introduction to Programming 1
Chapter 2: Hardware Fundamentals 11
Figure 2.1. RAM vs. CPU speeds 23
Figure 2.2. A memory hierarchy 26
Figure 2.3. The first few numbers 33
Figure 2.4. The next few numbers 33
Figure 2.5. How many combinations? 35
Figure 2.6. Binary to hex conversion table 46
Figure 2.7. Different representations of the same numbers 47
Figure 2.8. 32 and 16 bit registers, before add ax,1 50
Figure 2.9. 32 and 16 bit registers, after add ax,1 50
Figure 2.10. 32 and 16 bit registers, after add eax,1 51
Figure 2.11. 32 and 16 bit register codes 53
Figure 2.12. Instruction execution time, using registers and prefetching 62
Chapter 3: Basics of Programming 67
Figure 3.1. A little numeric calculation 72
Figure 3.2. A small section of RAM 78
Figure 3.3. One little endian value 81
Figure 3.4. A big endian example 81
Figure 3.5. Exercise 1 82
Figure 3.6. A really little numeric calculation 83
Figure 3.7. Compiling, part 1 84
Figure 3.8. Compiling, part 2 85
Figure 3.9. Compiling, part 3 86
Figure 3.10. Compiling, part 4 91
Figure 3.11. Before execution 93
Figure 3.12. After the first instruction is executed 94
Figure 3.13. After execution of second instruction 94
Figure 3.14. After execution of third instruction 95
Figure 3.15. After execution of final instruction 95
Figure 3.16. Some real characters and strings (code\basic00.cpp) 98
Figure 3.17. Yet another small section of RAM 106
Figure 3.18. Special characters for program text 109
Figure 3.19. A small section of RAM 109
Figure 3.20. Some simple output (code\basic01.cpp) 110
Figure 3.21. Some simple input and output (code\basic02.cpp) 111
Figure 3.22. Using an if statement (code\basic03.cpp) 113
Figure 3.23. Using a while statement (code\basic04.cpp) 115
Figure 3.24. A C++ program (code\pump1.cpp) 120
Figure 3.25. First dinner party program (code\basic05.cpp) 133
Figure 3.26. Second dinner party program (code\basic06.cpp) 135
Figure 3.27. else if example 135
Figure 3.28. Name and age program (code\basic07.cpp) 136
Figure 3.29. Novice program (code\basic08.cpp) 141
Figure 3.30. Allowance program (code\basic09.cpp) 143
Chapter 4: More Basics 149
Figure 4.1. Finding the top two weights, first try (code\pump1a.cpp) 150
Figure 4.2. Susan's solution to the bug in the first attempt 155
Figure 4.3. Using an if statement with an else clause 155
Figure 4.4. Finding the top two weights (code\pump2.cpp) 156
Figure 4.5. What if? 158
Figure 4.6. Using a Vec (code\vect1.cpp) 164
Figure 4.7. Using a for loop (from code\vect1.cpp) 170
Figure 4.8. Sorting the weights (from code\vect1.cpp) 179
Figure 4.9. Elements vs. values 181
Figure 4.10. Initial situation 190
Figure 4.11. After the first pass 190
Figure 4.12. After the second pass 191
Figure 4.13. Final situation 191
Figure 4.14. A possible error message 192
Figure 4.15. Sorting the weights, again (from code\vect1.cc) 192
Figure 4.16. Sorting the weights, with correct initialization (from code\vect2.cpp) 199
Figure 4.17. Garbage prevention, first attempt (from code\vect2a.cc) 203
Figure 4.18. Finding the top three weights using Vecs (code\vect3.cc) 204
Figure 4.19. Exercise 1 (code\morbas00.cpp) 210
Figure 4.20. Exercise 2 (code\morbas01.cpp) 210
Figure 4.21. Weight requesting program, first try (code\morbas02.cpp) 213
Figure 4.22. Error messages from the erroneous weight program (code\morbas02.cpp) 215
Figure 4.23. The corrected weight program (code\morbas03.cpp) 215
Figure 4.24. The weight totalling program (code\morbas04.cpp) 216
Chapter 5: Functional Literacy 219
Figure 5.1. A sample program with duplicated code (code\nofunc.cpp) 224
Figure 5.2. A function call 226
Figure 5.3. A function to average two values 229
Figure 5.4. Argument passing with one argument (code\birthday.cpp) 234
Figure 5.5. Using the Average function (code\func1.cpp) 239
Figure 5.6. Making an executable 250
Figure 5.7. A stack with one entry 259
Figure 5.8. A stack with two entries 259
Figure 5.9. A stack with three entries 259
Figure 5.10. An empty stack 263
Figure 5.11. The stack immediately after the call to Average 264
Figure 5.12. The stack after auto variable allocation 264
Figure 5.13. Scope vs. storage class 267
Figure 5.14. Using an auto variable and initializing it (code\count1.cpp) 270
Figure 5.15. Using an auto variable and not initializing it (code\count2.cpp) 271
Figure 5.16. Using a local static variable and initializing it explicitly (code\count3.cpp) 272
Figure 5.17. Using a local static variable and not initializing it explicitly (code\count4.cpp) 272
Figure 5.18. Using a global variable and initializing it explicitly (code\count5.cpp) 274
Figure 5.19. Using a global variable and not initializing it explicitly (code\count6.cpp) 274
Figure 5.20. Using variables of different scopes and storage classes (code\scopclas.cpp) 280
Figure 5.21. The results of using variables of different scopes and storage classes (code\scopclas.out) 281
Figure 5.22. The stack after the initialization of Result 285
Figure 5.23. The stack after exiting from Average 286
Figure 5.24. Exercise 1 (code\calc1.cpp) 290
Chapter 6: Taking Inventory 295
Figure 6.1. The initial sample program for the StockItem class (code\itemtst1.cpp) 307
Figure 6.2. Comparison between native and user-defined types 310
Figure 6.3. The initial interface of the StockItem class (code\item1.h) 316
Figure 6.4. The default constructor for the StockItem class (from code\item1.cpp) 321
Figure 6.5. Declaring the default constructor for the StockItem class 322
Figure 6.6. Another way to write the default StockItem constructor 324
Figure 6.7. Another constructor for the StockItem class (from code\item1.cpp) 334
Figure 6.8. Display member function for the StockItem class (from code\item1.cpp) 338
Figure 6.9. The initial interface of the StockItem class (code\item1.h) 341
Figure 6.10. The initial implementation of the StockItem class (code\item1.cpp) 342
Figure 6.11. Reading and displaying a Vec of StockItems (code\itemtst2.cpp) 345
Figure 6.12. The Read function for the StockItem class (from code\item2.cpp) 347
Figure 6.13. The second version of the interface for the StockItem class (code\item2.h) 350
Figure 6.14. The declaration of StockItem::Read in code\item2.h 352
Figure 6.15. First attempt to update inventory of StockItems (code\itemtst3.cpp) 361
Figure 6.16. Unauthorized access prohibited 364
Figure 6.17. An enhanced interface for the StockItem class (code\item4.h) 366
Figure 6.18. StockItem::CheckUPC (from code\item4.cpp) 368
Figure 6.19. StockItem::DeductSaleFromInventory (from code\item4.cpp) 369
Figure 6.20. StockItem::GetInventory (from code\item4.cpp) 369
Figure 6.21. StockItem::GetName (from code\item4.cpp) 369
Figure 6.22. Updating StockItem inventory (code\itemtst4.cpp) 370
Figure 6.23. Interface of Inventory class (code\invent1.h) 373
Figure 6.24. Default constructor for Inventory class (from code\invent1.cpp) 375
Figure 6.25. LoadInventory function for the Inventory class (from code\invent1.cpp) 376
Figure 6.26. The implementation of IsNull (from code\item5.cpp) 378
Figure 6.27. FindItem function for Inventory class (from code\invent1.cpp) 379
Figure 6.28. UpdateItem function for the Inventory class (from code\invent1.cpp) 380
Figure 6.29. The implementation of GetUPC (from code\item5.cpp) 381
Figure 6.30. The implementation of GetPrice (from code\item5.cpp) 382
Figure 6.31. Current interface for Inventory class (code\invent1.h) 382
Figure 6.32. Current implementation for Inventory class (code\invent1.cpp) 382
Figure 6.33. Current interface for StockItem class (code\item5.h) 384
Figure 6.34. Current implementation for StockItem class (code\item5.cpp) 385
Figure 6.35. Updated inventory application (code\itemtst5.cpp) 388
Figure 6.36. The Write member function for the StockItem class (from code\item6.cpp 403
Figure 6.37. The StoreInventory member function for the Inventory class (from code\invent2.cpp) 403
Figure 6.38. The changes to the application program (from code\itemtst6.cpp) 403
Chapter 7: Creating a Homegrown string class 405
Figure 7.1. Our string class interface, initial version (code\string1.h) 409
Figure 7.2. The initial implementation for the string class (code\string1.cpp) 410
Figure 7.3. The default constructor for our string class (from code\string1.cpp) 412
Figure 7.4. An empty string in memory 422
Figure 7.5. Our first test program for the string class (code\strtst1.cpp) 423
Figure 7.6. The char* constructor for our string class (from code\string1.cpp) 427
Figure 7.7. string n during construction 434
Figure 7.8. string n in memory 435
Figure 7.9. A simple test program for the string class (code\strtst1.cpp) 436
Figure 7.10. The char* constructor for the string class, again (from code\string1.cpp) 436
Figure 7.11. strings n and s in memory after compiler-generated = 439
Figure 7.12. strings n and s in memory after custom = 442
Figure 7.13. The declaration of operator = for the string class 447
Figure 7.14. Calling the operator = implementation 449
Figure 7.15. The assignment operator (operator =) for the string class (from code\string1.cpp) 450
Figure 7.16. Checking for an exception from new 456
Figure 7.17. A hypothetical assignment operator (operator =) for the string class with explicit this 462
Figure 7.18. The destructor for the string class (from code/string1.cpp) 465
Figure 7.19. Exercise 1 (code\strex1.cpp) 467
Figure 7.20. Exercise 2 (code\strex2.cpp) 468
Figure 7.21. Exercise 3 (code\strex3.cpp) 469
Chapter 8: Finishing Our homegrown string class 473
Figure 8.1. Call by value ("normal argument") using the compiler-generated copy constructor 474
Figure 8.2. Call by reference 476
Figure 8.3. Our first test program for the string class (code\strtst1.cpp) 477
Figure 8.4. Assigning a char* value to a string via string::string(char*) 479
Figure 8.5. The string class interface (code\string1.h) 483
Figure 8.6. The copy constructor for the string class (from code\string1.cpp) 484
Figure 8.7. The string class interface, with Display function (code\string3.h) 486
Figure 8.8. The latest version of the string class test program, using the Display function (code\strtst3.cpp) 486
Figure 8.9. The first few lines of the latest implementation of the string class (from string3.cpp) 487
Figure 8.10. The string class implementation of the Display function (from string3.cpp) 489
Figure 8.11. Dangerous characters (code\dangchar.cpp) 492
Figure 8.12. Reaping the whirlwind 495
Figure 8.13. The memory layout before overwriting the data 499
Figure 8.14. The memory layout after overwriting the data 500
Figure 8.15. Attempted privacy violation (code\strtst3a.cpp) 501
Figure 8.16. Trying to access a private member variable illegally 501
Figure 8.17. Yet another version of the string class interface (code\string4.h) 504
Figure 8.18. The string class implementation of the GetLength function (from code\string4.cpp) 505
Figure 8.19. Using the GetLength function in the string class (code\strtst4.cpp) 506
Figure 8.20. Sorting a Vec of strings (code\strsort1.cpp) 510
Figure 8.21. The updated string class interface, including comparison and I/O operators (code\string5.h) 513
Figure 8.22. strings x and y in memory 517
Figure 8.23. strings x and y in memory, with an embedded null byte 518
Figure 8.24. Using operator < for strings (code\strtst5x.cpp) 521
Figure 8.25. The implementation of operator < for strings (from code\string5a.cpp) 522
Figure 8.26. Is our character less than the one from the other string? (from code\string5a.cpp) 525
Figure 8.27. The else clause in the comparison loop (from code\string5a.cpp) 526
Figure 8.28. Handling the return value (from code\string5a.cpp) 527
Figure 8.29. Implementing operator < for strings (from code\string5.cpp) 528
Figure 8.30. Implementing operator == for strings (from code\string5.cpp) 532
Figure 8.31. Chaining several operator << expressions together (code\cout1.cpp) 534
Figure 8.32. An operator << function to output a string (from code\string5.cpp) 537
Figure 8.33. Why operator << has to be implemented via a global function 540
Figure 8.34. A operator >> function to input a string (from code\string5.cpp) 540
Figure 8.35. Error from an uninitialized const (code\string5x.err) 542
Figure 8.36. Use of a non-const array size (code\string5y.cpp) 544
Figure 8.37. Exercise 1 (code\strex5.cpp) 551
Figure 8.38. Exercise 2 (code\strex6.cpp) 552
Figure 8.39. The string class interface file (from code\string6.h) 555
Figure 8.40. The string class implementation of operator > (from code\string6.cpp) 556
Figure 8.41. The string class implementation of operator >= (from code\string6.cpp) 556
Figure 8.42. The string class implementation of operator != (from code\string6.cpp) 557
Figure 8.43. The string class implementation of operator <= (from code\string6.cpp) 557
Figure 8.44. The test program for the comparison operators of the string class (code\strcmp.cpp) 558
Chapter 9: Inheritance 563
Figure 9.1. The next StockItem header file (code\item20.h) 568
Figure 9.2. The next implementation of StockItem (code\item20.cpp) 570
Figure 9.3. The next header file for the Inventory class (code\invent20.h) 574
Figure 9.4. The StockItem test program for the base StockItem class (code\itmtst20.cpp) 576
Figure 9.5. The implementation of the Inventory class (code\invent20.cpp) 577
Figure 9.6. The Reorder function for the StockItem class (from code\item20.cpp) 580
Figure 9.7. Simplified interface for StockItem and DatedStockItem classes (code\itema.h) 585
Figure 9.8. A simplified StockItem object 586
Figure 9.9. A DatedStockItem object 587
Figure 9.10. A derived class object with its base class part 600
Figure 9.11. The next version of the inventory control test program (code\itmtst21.cpp) 602
Figure 9.12. Full interface for StockItem and DatedStockItem (code\item21.h) 604
Figure 9.13. Latest implementation of StockItem class and first implementation of DatedStockItem class (code\item21.cpp) 606
Figure 9.14. DatedStockItem::Today() (from code\item21.cpp) 618
Figure 9.15. A simple stream example (code\stream1.cpp) 621
Figure 9.16. An empty ostream object 622
Figure 9.17. An ostream object with some data 623
Figure 9.18. An ostream object with some more data. 623
Figure 9.19. An empty ostream object 624
Figure 9.20. A stringstream formatting example (code\stream2.cpp) 624
Figure 9.21. An empty stringstream object 625
Figure 9.22. A stringstream object with some contents 627
Figure 9.23. A stringstream object with some more contents 628
Figure 9.24. A stringstream object with even more contents 628
Figure 9.25. A stringstream object after reading its contents 629
Figure 9.26. Default formatting example (code\coutdef1.cpp) 630
Figure 9.27. Output of default formatting example (code\coutdef1.out) 631
Figure 9.28. Output of controlled formatting example (code\coutdef2.out) 632
Figure 9.29. Controlled formatting example (code\coutdef2.cpp) 632
Figure 9.30. Default constructor for DatedStockItem (from code\item21.cpp) 635
Figure 9.31. Specifying the base class constructor for a derived class object 636
Figure 9.32. Constructing a default DatedStockItem object 638
Figure 9.33. Normal constructor for DatedStockItem (from code\item21.cpp) 639
Figure 9.34. Constructing a DatedStockItem object 640
Figure 9.35. The Reorder function for DatedStockItem (from code\item21.cpp) 642
Figure 9.36. Calling Reorder through a StockItem pointer, part 1 645
Figure 9.37. Calling Reorder through a DatedStockItem pointer 646
Figure 9.38. Calling Reorder through a StockItem pointer, part 2 647
Figure 9.39. Function call example (code\nvirtual.cpp) 647
Figure 9.40. Function call example output (code\nvirtual.out) 648
Figure 9.41. Simplified implementation for StockItem and DatedStockItem classes (code\itema.cpp) 649
Chapter 10: Polymorphism 657
Figure 10.1. Dangerous polymorphism: Interfaces of StockItem and DatedStockItem with virtual Reorder function (code\itemb.h) 663
Figure 10.2. virtual function call example output (code\virtual.out) 664
Figure 10.3. A simplified StockItem object without virtual functions 666
Figure 10.4. Dangerous polymorphism: A simplified StockItem object with a virtual function 668
Figure 10.5. Dangerous polymorphism: A simplified DatedStockItem object with a virtual function 669
Figure 10.6. Dangerous polymorphism: Calling a virtual Reorder function through a StockItem pointer to a StockItem object 670
Figure 10.7. Dangerous polymorphism: Calling a virtual Reorder function through a DatedStockItem pointer to a DatedStockItem object 671
Figure 10.8. Dangerous polymorphism: Calling a virtual Reorder function through a StockItem pointer to a DatedStockItem object 672
Figure 10.9. Dangerous polymorphism: A simplified StockItem object with two virtual functions 674
Figure 10.10. Dangerous polymorphism: A simplified DatedStockItem with two virtual functions 675
Figure 10.11. Dangerous polymorphism: Using operator << with a StockItem* (code\polyioa.cpp) 676
Figure 10.12. Result of using operator << with a StockItem* (code\polyioa.out) 677
Figure 10.13. Dangerous polymorphism: StockItem interface with operator << and operator >> (code\itemc.h) 677
Figure 10.14. Dangerous polymorphism: StockItem implementation with operator << and operator >> (code\itemc.cpp) 680
Figure 10.15. Dangerous polymorphism: The implementation of operator << with a StockItem* (from code\itemc.cpp) 687
Figure 10.16. Dangerous polymorphism: StockItem::Write (from code\itemc.cpp) 688
Figure 10.17. Dangerous polymorphism: DatedStockItem::Write (from code\itemc.cpp) 688
Figure 10.18. Dangerous polymorphism: Using operator >> and operator << with a StockItem* (code\polyiob.cpp) 689
Figure 10.19. Dangerous polymorphism: The results of using operator >> and operator << with a StockItem* (code\polyiob.out) 690
Figure 10.20. Dangerous polymorphism: The implementation of operator >> (from code\itemc.cpp) 692
Figure 10.21. Safe polymorphism: Using operator >> and operator << with a polymorphic StockItem (code\polyioc.cpp) 696
Figure 10.22. Safe polymorphism: The polymorphic object version of the StockItem interface (code\itemp.h) 697
Figure 10.23. Safe polymorphism: The UndatedStockItem and DatedStockItem interfaces for the polymorphic version of StockItem (code\itempi.h) 700
Figure 10.24. Safe polymorphism: The implementation of the UndatedStockItem and DatedStockItem classes (code\itemp.cpp) 701
Figure 10.25. Safe polymorphism: The implementation of operator << for a polymorphic StockItem (from code\itemp.cpp) 710
Figure 10.26. Safe polymorphism: A polymorphic StockItem object with no date 712
Figure 10.27. Safe polymorphism: A polymorphic StockItem object with a date 713
Figure 10.28. A simplified version of the structure of a DatedStockItem object 715
Figure 10.29. Safe polymorphism: The default constructor for the polymorphic StockItem class (from code\itemp.cpp) 716
Figure 10.30. Safe polymorphism: A default-constructed polymorphic StockItem object 718
Figure 10.31. Safe polymorphism: The default constructor for the UndatedStockItem class (from code\itemp.cpp) 719
Figure 10.32. Safe polymorphism: Implementing a special protected constructor for StockItem (from code\itemp.cpp) 721
Figure 10.33. Safe polymorphism: An example program for reference-counting with StockItems (code\refcnt1.cpp) 724
Figure 10.34. Safe polymorphism: A normal constructor to create a StockItem without a date (from code\itemp.cpp) 725
Figure 10.35. Safe polymorphism: A polymorphic StockItem object with an UndatedStockItem worker 727
Figure 10.36. Safe polymorphism: A normal constructor that constructs a StockItem having a date (from code\itemp.cpp) 727
Figure 10.37. Safe polymorphism: A polymorphic StockItem object with a DatedStockItem worker 728
Figure 10.38. Safe polymorphism: The copy constructor for StockItem (from code\itemp.cpp) 728
Figure 10.39. Safe polymorphism: Two polymorphic StockItem objects sharing the same UndatedStockItem worker object 730
Figure 10.40. Safe polymorphism: The assignment operator (operator =) for StockItem (from code\itemp.cpp) 731
Figure 10.41. Safe polymorphism: Two polymorphic StockItem objects sharing the same DatedStockItem worker object 733
Figure 10.42. Safe polymorphism: A polymorphic StockItem object 735
Figure 10.43. Safe polymorphism: The destructor for the StockItem class (from code\itemp.cpp) 735
Figure 10.44. Safe polymorphism: The destructor for the StockItem class (from code\itemp.cpp) 740
Chapter 11: The Home Inventory Project 753
Figure 11.1. The initial interface for the HomeItem manager class (code/hmit1.h) 758
Figure 11.2. The initial interface for the HomeItemBasic and HomeItemMusic worker classes (code\hmiti1.h) 761
Figure 11.3. The initial test program for the HomeItem classes (code\hmtst1.cpp) 765
Figure 11.4. Results of running the first HomeItem test program (code\hmit1.out) 766
Figure 11.5. Initial implementation of HomeItem manager and worker classes (code\hmit1.cpp) 766
Figure 11.6. HomeItem::Write (from code\hmit1.cpp) 773
Figure 11.7. The HomeItem implementation of operator >> (from code\hmit1.cpp) 774
Figure 11.8. The (incorrect) while loop in the original implementation of operator >> 777
Figure 11.9. A legal program (code\fortest.cpp) 780
Figure 11.10. An incorrect default constructor for the HomeItemBasic class (strzero.err) 781
Figure 11.11. HomeItemBasic::GetType (from code\hmit1.cpp) 782
Figure 11.12. HomeItemMusic::GetType (from code\hmit1.cpp) 782
Figure 11.13. HomeItemBasic::Write (from code\hmit1.cpp) 783
Figure 11.14. HomeItemMusic::Write (from code\hmit1.cpp) 783
Figure 11.15. The initial HomeInventory class interface (code\hmin2.h) 787
Figure 11.16. The initial implementation of HomeInventory (code\hmin2.cpp) 788
Figure 11.17. Yet another implementation of LoadInventory (from code\hmin3.cpp) 794
Figure 11.18. The next interface for the HomeInventory class (code\hmin4.h) 797
Figure 11.19. The AddItem member function of HomeInventory (from code\hmin4.cpp) 798
Figure 11.20. The new interface for HomeItem (code\hmit4.h) 800
Figure 11.21. The implementation of HomeItem::NewItem() (from code\hmit4.cpp) 801
Figure 11.22. The new version of operator >> (from code\hmit4.cpp) 802
Figure 11.23. HomeItemBasic::FormattedDisplay (from code\hmit4.cpp) 807
Figure 11.24. HomeItemMusic::FormattedDisplay (from code\hmit4.cpp) 807
Figure 11.25. The test program for adding a HomeItem interactively (hmtst4.cpp) 809
Figure 11.26. The next version of the interface for HomeInventory (code\hmin5.h) 810
Figure 11.27. The next version of the HomeInventory test program (code\hmtst5.cpp) 811
Figure 11.28. The EditItem function of HomeInventory (from code\hmin5.cpp) 813
Figure 11.29. The latest version of the Homeitem class interface (code\hmit5.h) 814
Figure 11.30. HomeItem::Edit (from code\hmit5.cpp) 815
Figure 11.31. HomeItemBasic::CopyData() (from code\hmit5.cpp) 817
Figure 11.32. The latest version of operator >> (from code\hmit5.cpp) 818
Figure 11.33. The latest version of the interface for the HomeItem worker classes (code\hmiti5.h) 821
Figure 11.34. HomeItemBasic::GetFieldName (from code\hmit5.cpp) 826
Figure 11.35. HomeItem::Read (from code\hmit5.cpp) 828
Figure 11.36. HomeItemBasic::Read (from code\hmit5.cpp) 829
Figure 11.37. HomeItemBasic::ReadInteractive (from code\hmit5.cpp) 830
Figure 11.38. HomeItemBasic::ReadFromFile (from code\hmit5.cpp) 833
Figure 11.39. HomeItemBasic::Edit (from code\hmit5.cpp) 834
Figure 11.40. HomeItemBasic::FormattedDisplay (from code\hmit5.cpp) 835
Figure 11.41. HomeItemBasic::EditField (from code\hmit5.cpp) 836
Figure 11.42. HomeItemMusic::FormattedDisplay (from code\hmit5.cpp) 839
Figure 11.43. HomeItemMusic::ReadInteractive (from code\hmit5.cpp) 842
Figure 11.44. HomeItemMusic::ReadFromFile (from code\hmit5.cpp) 843
Figure 11.45. HomeItemMusic::EditField (from code\hmit5.cpp) 843
Chapter 12: More on the Home Inventory Project 855
Figure 12.1. The new xstring class interface (code\xstring.h) 862
Figure 12.2. The default constructor for the xstring class (from code\xstring.h) 866
Figure 12.3. The copy constructor for the xstring class (from code\xstring.h) 866
Figure 12.4. Another constructor for the xstring class (from code\xstring.h) 867
Figure 12.5. A little test program for an early version of the xstring class (code\xstrtstc.cpp) 868
Figure 12.6. An early version of the xstring header file (code\xstringc.h) 869
Figure 12.7. An error message from mixing strings and xstrings 870
Figure 12.8. Another version of the xstring header file (code\xstringd.h) 870
Figure 12.9. A successful attempt to mix strings and xstrings (code\xstrtstd.cpp) 871
Figure 12.10. The char* constructor for the xstring class (from code\xstring.h) 871
Figure 12.11. Another constructor for the xstring class (from code\xstring.h) 872
Figure 12.12. The final constructor for the xstring class (from code\xstring.h) 872
Figure 12.13. An illegal program (code\strzero.cpp) 873
Figure 12.14. The error message from compiling that illegal program (code\strzero.err) 873
Figure 12.15. A legal but dubious program (code\strone.cpp) 874
Figure 12.16. The final version of the xstring header file (code\xstring.h) 876
Figure 12.17. An illegal program (code\strfix.cpp) 877
Figure 12.18. The error message from strfix.cpp (code\strfix.err) 877
Figure 12.19. Using xstring::find_nocase (code\xstrtstb.cpp) 881
Figure 12.20. The implementation of xstring::find_nocase (from code\xstring.cpp) 883
Figure 12.21. The less_nocase function (from code\xstring.cpp) 887
Figure 12.22. The latest home inventory application program (code\hmtst6.cpp) 888
Figure 12.23. The latest version of the HomeInventory interface (hmin6.h) 889
Figure 12.24. HomeInventory::FindItemByDescription (from code\hmin6.cpp) 891
Figure 12.25. The new version of the HomeItem interface (code\hmit6.h) 892
Figure 12.26. HomeItemBasic::IsNull (from code\hmit6.cpp) 894
Chapter 13: Analyzing the Home Inventory Project 911
Figure 13.1. The main() function of the final version of the home inventory main program (from code\hmtst8.cpp) 913
Figure 13.2. The MenuItem enum (from code\hmtst8.cpp) 915
Figure 13.3. The GetMenuChoice function (from code\hmtst8.cpp) 915
Figure 13.4. ExecuteMenuChoice (from code\hmtst8.cpp) 918
Figure 13.5. The HomeUtility interface (code\hmutil1.h) 925
Figure 13.6. Not declaring a default argument (code\nodef.h) 928
Figure 13.7. Not using a default argument (code\nodef.cpp) 928
Figure 13.8. Declaring a default argument (code\default.h) 929
Figure 13.9. Using a default argument (code\nodef.cpp) 929
Figure 13.10. HomeUtility::ReadDoubleFromLine (from code\hmutil1.cpp) 930
Figure 13.11. HomeUtility::ReadLongFromLine (from code\hmutil1.cpp) 931
Figure 13.12. HomeUtility::ReadDateFromLine (from code\hmutil1.cpp) 932
Figure 13.13. HomeUtility::IgnoreTillCR (from code\hmutil1.cpp) 933
Figure 13.14. HomeUtility::HandleError (from code\hmutil1.cpp) 934
Figure 13.15. HomeUtility::CheckNumericInput (from code\hmutil1.cpp) 935
Figure 13.16. HomeUtility::GetNumberOrEnter (from code\hmutil1.cpp) 938
Figure 13.17. HomeUtility::ClearRestOfScreen (from code\hmutil1.cpp) 947
Figure 13.18. The HomeUtility::SelectItem function (from code\hmutil1.cpp) 949
Figure 13.19. The latest header file for the HomeInventory class (code\hmin8.h) 955
Figure 13.20. The latest version of HomeInventory::AddItem (from code\hmin8.cpp) 957
Figure 13.21. The latest version of HomeInventory::EditItem (from code\hmin8.cpp) 958
Figure 13.22. The latest version of HomeInventory::LocateItemByDescription (from code\hmin8.cpp) 959
Figure 13.23. HomeInventory::LocateItemByCategory (from code\hmin8.cpp) 960
Figure 13.24. The HomeInventory::PrintNames function (from code\hmin8.cpp) 961
Figure 13.25. The HomeInventory::PrintAll function (from code\hmin8.cpp) 962
Figure 13.26. The HomeInventory::StoreInventory function (from code\hmin8.cpp) 963
Figure 13.27. The HomeInventory::DisplayItem function (from code\hmin8.cpp) 964
Figure 13.28. The HomeInventory::SortInventoryByName function (from code\hmin8.cpp) 965
Figure 13.29. The HomeInventory::SelectItemByPartialName function (from code\hmin8.cpp) 966
Figure 13.30. The HomeInventory::SelectItemFromNameList function (from code\hmin8.cpp) 968
Figure 13.31. The HomeInventory::SelectItemFromCategoryList function (from code\hmin8.cpp) 969
Figure 13.32. The HomeInventory::DeleteItem function (from code\hmin8.cpp) 973
Figure 13.33. The new operator >> implementation for the HomeItem classes (from code\hmit8.cpp) 974
Figure 13.34. The latest version of HomeItemBasic::Edit (from code\hmit8.cpp) 976
Figure 13.35. The latest version of HomeItemBasic::ReadInteractive (from code\hmit8.cpp) 977
Figure 13.36. The latest version of the HomeItemBasic::EditItem function (from code\hmit8.cpp) 979
Figure 13.37. The latest version of HomeItemMusic::ReadInteractive (from code\hmit8.cpp) 980
Figure 13.38. The latest version of HomeItemMusic::EditField (from code\hmit8.cpp) 982

TOC PREV NEXT INDEX