A Beginners C++
The table of contents given below includes links to additional materials. Some complete chapters, and various subsections, are available either as Postscript files or directly readable "html" text. There are also links to a couple of files with example code. The code should be usable with the Borland development environment for the PC, or Symantec-8 for the Macintosh.
To save space and transmission time, many of the Postscript files have been compressed. The files were compressed using gzip on Unix. You have to uncompress them (gunzip) before viewing them with ghostview or sending to a printer. (If you go to Javaworld you will usually find that they have dowloadable copies of gzip utilities for both Mac and PC available on their page. The links are at the bottom after their stories about Java developments.) (If you need a viewer for postscript, try: University Wisconsin, ghostscript, ghostview, gs page )
The postscript files have been "distilled" into Adobe PDF files. This makes them smaller, and so easier to download; it should also make them easier to read on a variety of systems.
Preface
(PDF of table of contents)Part 1 Introduction to Computers
- Computer Hardware
(Postscript file of Computer Hardware Chapter)- CPU and instructions
- Memory and Data
- Bus
- Peripherals
- Disks and tapes
- Other I/O devices
- Programs: Instructions in the Computer (PDF of chapter)
- Programming with bits!
- Loaders
- Assemblers
- Coding in assembly language
- From Assembly Language to "High Level" languages
- Operating Systems
(Postscript file of Operating Systems chapter)- Origins of "Operating Systems"
- Development of Operating Systems: Multiprogramming* Timesharing* File Management* Virtual Memory* "Spooling"* Late 1960s early 1970s system* Networking*
- Modern systems: UNIX* Macintosh OS*
- Why have "high-level" languages? (Postscript file of chapter)
- Limitations of Assembly Language and Origins of High Level Languages
- High level languages constructs: Statements* Data types and structures*
- Evolution of high level languages
- FORTRAN
- BASIC
- Lisp
- COBOL
- ALGOL
- The "Algol Family":AlgolW, Pascal, and Modula2* ADA* BCPL, C, and C++* Simula, SmallTalk, and Eiffel*
- C++ development environment (Postscript file of chapter)
- Integrated Development Environment
- C++ input and output
- A simple example program in C++:Design* Implementation*
Part 2 Simple Programs
- Sequence (PDF of chapter)
- Overall structure and main() Function
- Comments
- Variable definitions
- Statements
- Examples: "Exchange rates"* pH*
- Naming rules for variables
- Constants
- Initialization of Variables
- Converting data values
- Iteration (PDF of chapter)
- While loops
- Examples: Modelling the decay of CFC gases* Newton's method for finding a square root* Tabulating function values*
- Blocks
- "Boolean" variables and expressions True and False* Expressions using "AND"s and "OR"s*
- Short forms: C/C++ abbreviations
- Do ... while
- For loop
- Break and Continue statements
- Selection (PDF of chapter)
- Making choices
- A realistic program: Desk Calculator
- IF...
- Terminating a program
- Example Programs: Calculating some simple statistics* Newton's method for roots of polynomials*
- What is the Largest? What is the Smallest?
- Simple use of files
- Dealing with more data
- Defining filestream objects
- Using input and output filestreams
- Stream states
- Options when opening filestreams
- When to stop reading data?
- More Formatting options
- Example (html text of most of section on files) (PDF of chapter)
Part 3 Functions and Data Aggregates
- Functions (PDF of chapter)
- Form of a function Definition
- Result types
- Function declarations
- Default argument values
- Type safe linkage, Overloading, and Name Mangling
- How functions work
- Inline functions
- A recursive function
- Examples of simple functions: GetIntegerInRange* Newton's square root algorithm as a function*
- The rand() function
- Examples: pi-Canon* (html text of section introducing coding example), (text file with all code for pi-cannon) Function plotter*
- Arrays (Postscript file of chapter)
- Defining one dimensional arrays
- Initializing one dimensional arrays
- Simple Examples Using One-Dimensional arrays: Histogram* Plotting once more*
- Arrays as arguments to functions
- Strings: Arrays of characters
- Multi-dimensional arrays: Definition and initialization* Accessing individual elements* As arguments to functions*
- Arrays of Fixed length Strings
- Examples using arrays: Letter Counts* Simple encryption* Simple image processing*
- Programs with functions and arrays (postscript file of chapter with several examples using functions and arrays)
- Curses
- Heat diffusion
- Menu Selection
- Pick the keyword
- Hangman (html text of section introducing hangman problem), (text file with all hangman code)
- Life
- Standard algorithms(Postscript text of chapter on standard searching and sorting functions)
- Finding the Right Element: Binary Search: An iterative binary search routine* Isn't it a recursive problem?* What was the cost?
- Establishing Order
- A simple sort of sort
- Quicksort: a better sort of sort: The algorithm* An implementation* An enhanced implementation* (html text of section on Quicksort) (PDF of chapter)
- Algorithms, Functions, and Subroutine Libraries
- Tools (html text chapter on support tools for program development),
- The "Code Coverage" Tool
- The Profiler
- Design and documentation : 1
- Top down functional decomposition
- Documenting a design
- Enum, Struct, and Union
- Enumerated types
- structs
- Unions(html text of section on C/C++ Unions)
- Examples using structs
- Reordering the class list again
- Points and Rectangles
- File of Records
- Bits and pieces(Postscript file for chapter explaining role of bit-level operations in C/C++)
- Bit manipulations
- Making a Hash of it: Example hashing function for a character string* A simple "hash table"* Example: identifying the commonly used words*
- Coding "Property Vectors"
- Pieces (Bit fields) (PDF of chapter)
Part 4 A Touch of Class
- Beginners' Class
- Class declarations and definitions: Form of a class declaration* Defining the member functions* Using class instances* Initialization and "constructor" functions* const member functions* inline member functions*
- Example: Bitmaps (Sets)
- Numbers - a more complex form of data (details of a class for +, -, *, /, on 100 digit numbers; as a postscript file) code of multidigit arithmetic class
- A glance at the "iostream" classes
- Dynamic data and pointers (Postscript file of chapter)
- The "Heap"
- Pointers: Some "pointer" basics* Using pointers* Strings and hash tables revisited*
- Example: "Air Traffic Controller"
- The "address of" operator
- Pointers and Arrays
- Building Networks
- Collections of data (postscript file of chapter presenting several standard "collection class" abstract types)
- Class Queue
- Class PriorityQueue
- Class DynamicArray (code in C29 and C30 examples)
- Class List
- Class BinaryTree (code in C23 iterators example)
- Collection class Libraries
- A World of Interacting Objects
- RefCards: Design* Implementation*
- InfoStore: Initial design outline for InfoStore* Design and Implementation of the Vocabulary class* Other classes in the InfoStore program* Final class design for the InfoStore program (Postscript file, long case studies suggesting how to identify and then characterize objects and their classes
- Intermediate class
- Shared Class Properties
- Friends
- Iterators: ListIterator* TreeIterator*(html file on Iterators for collection classes), (example code with tree iterator)
- Operator functions: Defining operator functions* Operator functions and the iostream library*
- Resource Manager Classes and Destructors: Resource management* Destructor functions* The assignment operator and copy constructors*
- Inheritance: Discovering similarities among prototype classes* Defining Class Hierarchies in C++* But how does it work?!* Multiple Inheritance* Using Inheritance (html file of section introducing inheritance and C++ class hierarchies)
- Two more "trees"(Postscript file of chapter on AVL trees and Btree storage structures)
- AVL Trees: What's wrong with binary trees?* Keeping your balance* An implementation* Testing!*(code for an AVL tree class)
- BTree: Multiway trees* A tree on a disk?* BTree: search, insertion, and deletion operations* An implementation* Testing* (code in C30 example)
- Templates (Postscript file of Templates chapter)
- A general function and its specializations
- Language Extensions for Templates:Template declaration* Template instantiation*
- Specialized Instantiations of Template Code
- A Template Version of QuickSort
- The Template Class "Bounded Array"
- The Template Class Queue
- Exceptions (Postscript file of Exceptions chapter)
- C++'s Exception Mechanism
- Example: Exceptions for class Number
- Identifying the Exceptions that you intend to throw
- Example: Supermarket
- Background and Program Specification/li>
- Design: Design preliminaries* Scenarios: identifying objects, their classes, their responsibilities, their data* Filling out the definitions of the classes for a partial implementation*
- A partial implementation
- Finalising the Design: Histograms* Simulating the checkouts and their queues* Organizing the checkouts*
- Design and documentation: 2
- Object-Based Design
- Documenting a design
Part 5 Object Oriented Programming
(Paper describing approach to teaching OO)
- The Power of Inheritance and Polymorphism (postscript file, of chapter with example illustrating use of inheritance and polymorphism)
- The "Dungeon" Game
- Design: Preliminaries* WindowRep and Window classes* DungeonItem hierarchy*(html text of chapter with example illustraing inheritance)
- An implementation: Windows classes* Class Dungeon* DungeonItems*( html text of chapter with example illustraing inheritance), (the code for "dungeon game" example)
- Reusable designs
- The RecordFile Framework: Concepts(html text)
- The Framework classes: Overview
- The Command Handler Classes: Class declarations* Interactions* Implementation Code*
- Collection Classes and their Adapters*
- Class Record
- The Windows Class Hierarchy: Class Responsibilities* Implementation Code* Using the concrete classes from a framework*
- Organizational Details (Student Rec application, example use of a framework) (code for a simplified framework class library and application) (PDF of chapter)
- Frameworks for understanding(Postscript file introducing standard framework class libraries)
- "Resources" and "Macros"
- Architects, Experts, and Wizards
- Graphics
- Persistent Data
- The Event Handlers
- The Same Patterns in the code