Sciweavers


Book

A Beginners C++

15 years 10 months ago
A Beginners C++
"This book is primarily intended to be a text for the programming component in an introductory two semester computer science course (some materials are a little advanced and might postponed to later semesters). However, the book should be equally suited to an individual who wants to learn how to program their own personal computer. It assumes an audience that is computer literate, but without previous programming experience. It further assumes that readers will be working with one of the modern "Integrated Development Environments" (IDE) on a personal computer (e.g. the Borland environment for Intel PCs or the Symantec environment for Macintosh/PowerPC machines). Example code provided should run in both environments."
Neil Gray
Added 14 Feb 2009
Updated 14 Feb 2009
Authors Neil Gray

Table of Contents

Part I Introduction
1 Computer Hardware
1.1 CPU and instructions
1.2 Memory AND DATA
1.3 Bus
1.4 Peripherals
1.4.1 Disks and tapes
1.4.2 Other I/O devices
2 Programs: Instructions in the Computer
2.1 Programming with bits!
2.2 Loaders
2.3 Assemblers
2. 4 Coding in assembly language
2.5 From Assembly Language to "High Level" languages
3 Operating Systems
3.1 Origins of "Operating Systems"
3.2 Development of Operating Systems
3.2.1 Multiprogramming
3.2.2 Timesharing
3.2.3 File Management
3.2.4 Virtual Memory
3.2.5 "Spooling"
3.2.6 Late 1960s early 1970s system
3.3 Networking
3.4 Modern systems
3.4.1 UNIX
3.4.2 Macintosh OS
4 Why have "high-level" languages?
4.1 Limitations of Assembly Language and Origins of High Level Languages
4.2 High level languages constructs
4.2.1 Statements
4.2.2 Data types and structures
4.3 Evolution of high level languages
4.4 FORTRAN
4.5 BASIC
4.6 Lisp
4.7 COBOL
4.8 ALGOL
4.9 The "Algol Family"
4.9.1 AlgolW, Pascal, and Modula2
4.9.2 ADA
4.9.3 BCPL, C, and C++
4.9.4 Simula, SmallTalk, and Eiffel
5 C++ development environment
5.1 Integrated Development Environment
5.2 C++ input and output
5.3 A simple example program in C++
5.3.1 Design
5.3.2 Implementation
Part II Simple Programs
6 Sequence
6.1 Overall structure and main() Function
6.2 Comments
6.3 Variable definitions
6.4 Statements
6.5 Examples
6.5.1 "Exchange rates"
6.5.2 pH
6.6 Naming rules for variables
6.7 Constants
6.7.1 Example program with some const definitions.
6.8 Initialization of Variables
6.9 Converting data values
7 Iteration
7.1 While loops
7.2 Examples
7.2.1 Modelling the decay of CFC gases
7.2.2 Newton's method for finding a square root
7.2.3 Tabulating function values
7.3 Blocks
7.4 "Boolean" variables and expressions
7.4.1 True and False
7.4.2 Expressions using "AND"s and "OR"s
7.5 Short forms: C/C++ abbreviations
7.6 Do …While
7.7 For loop
7.8 Break and Continue statements
8 Selection
8.1 Making choices
8.2 A realistic program: Desk Calculator
8.3 IF…
8.4 Terminating a program
8.5 Example Programs
8.5.1 Calculating some simple statistics
8.5.2 Newton's method for roots of polynomials
8.6 What is the Largest? What is the Smallest?
9 Simple use of files
9.1 Dealing with more data
9.2 Defining filestream objects
9.3 Using input and output filestreams
9.4 Stream states
9.5 Options when opening filestreams
9.6 When to stop reading data?
9.7 More Formatting options
9.8 Example
Part III Functions and Data Aggregates
10 Functions
10.1 Form of a function Definition
10.2 Result types
10.3 Function declarations
10.4 Default argument values
10.5 Type safe linkage, Overloading, and Name Mangling
10.6 How functions work
10.7 Inline functions
10.8 A recursive function
10.9 Examples of simple functions
10.9.1 GetIntegerInRange
10.9.2 Newton's square root algorithm as a function
10.10 The rand() function
10.11 Examples
10.11.1 ð-Canon
10.11.2 Function plotter
11 Arrays
11.1 Defining one dimensional arrays
11.2 Initializing one dimensional arrays
11.3 Simple Examples Using One-Dimensional arrays
11.3.1 Histogram
11.3.2 Plotting once more
11.4 Arrays as arguments to functions
11.5 Strings: Arrays of characters
11.6 Multi-dimensional arrays
11.6.1 Definition and initialization
11.6.2 Accessing individual elements
11.6.3 As arguments to functions
11.7 Arrays of Fixed length Strings
11.8 Examples using arrays
11.8.1 Letter Counts
11.8.2 Simple encryption
11.8.3 Simple image processing
12 Programs with functions and arrays
12.1 Curses
12.2 Heat diffusion
12.3 Menu Selection
12.4 Pick the keyword
12.5 Hangman
12.6 Life
13 Standard algorithms
13.1 Finding the Right Element: Binary Search
13.1.1 An iterative binary search routine
13.1.2 Isn't it a recursive problem?
13.1.3 What was the cost?
13.2 Establishing Order
13.3 A simples sort of sort
13.4 Quicksort: a better sort of sort
13.4.1 The algorithm
13.4.2 An implementation
13.4.3 An enhanced implementation
13.5 Algorithms, Functions, and Subroutine Libraries
14 Tools
14.1 The "Code Coverage" Tool
14.2 The Profiler
15 Design and documentation : 1
15.1 Top down functional decomposition
15.2 Documenting a design
16 Enum, Struct, and Union
16.1 Enumerated types
16.2 Structs
16.3 Unions
17 Examples using structs
17.1 Reordering the class list again
17.2 Points and Rectangles
17.3 File of Records
18 Bits and pieces
18.1 Bit manipulations
18.2 Making a Hash of it
18.2.1 Example hashing function for a character string
18.2.2 A simple "hash table"
18.2.3 Example: identifying the commonly used words
18.3 Coding "Property Vectors"
18.4 Pieces (Bit fields)
Part IV
19 Beginners' Class
19.1 Class declarations and definitions
19.1.1 Form of a class declaration
19.1.2 Defining the member functions
19.1.3 Using class instances
19.1.4 Initialization and "constructor" functions
19.1.5 const member functions
19.1.6 inline member functions
19.2 Example: Bitmaps (Sets)
19.3 Numbers – a more complex form of data
19.4 A glance at the "iostream" classes
20 Dynamic data and pointers
20.1 The "Heap"
20.2 Pointers
20.2.1 Some "pointer" basics
20.2.2 Using pointers
20.2.3 Strings and hash tables revisited
20.3 Example: "Air Traffic Controller"
20.4 & : the "address of" operator
20.5 Pointers and Arrays
20.6 Building Networks
21 Collections of data
21.1 Class Queue
21.2 Class PriorityQueue
21.3 Class DynamicArray
21.4 Class List
21.5 Class BinaryTree
21.6 Collection class Libraries
22 A World of Interacting Objects
22.1 RefCards
22.1.1 Design
22.1.2 Implementation
22.2 InfoStore
22.2.1 Initial design outline for InfoStore
22.2.2 Design and Implementation of the Vocabulary class
22.2.3 Other classes in the InfoStore program
22.2.4 Final class design for the InfoStore program
23 Intermediate class
23.1 Shared Class Properties
23.2 Friends
23.3 Iterators
23.3.1 ListIterator
23.3.2 TreeIterator
23.4 Operator functions
23.4.1 Defining operator functions
23.4.2 Operator functions and the iostream library
23.5 Resource Manager Classes and Destructors
23.5.1 Resource management
23.5.2 Destructor functions
23.5.3 The assignment operator and copy constructors
23.6 Inheritance
23.6.1 Discovering similarities among prototype classes
23.6.2 Defining Class Hierarchies in C++
23.6.3 But how does it work?!
23.6.4 Multiple Inheritance
23.6.5 Using Inheritance
24 Two more "trees"
24.1 AVL Trees
24.1.1 What's wrong with binary trees?
24.1.2 Keeping your balance
24.1.3 An implementation
24.1.4 Testing!
24.2 BTree
24.2.1 Multiway trees
24.2.2 A tree on a disk?
24.2.3 BTree: search, insertion, and deletion operations
24.2.4 An implementation
24.2.5 Testing
25 Templates
25.1 A general function and its specializations
25.2 Language Extensions for Templates
25.2.1 Template declaration
25.2.2 Template instantiation
25.3 Specialized Instantiations of Template Code
25.4 A Template Version of QuickSort
25.5 The Template Class "Bounded Array"
25.6 The Template Class Queue
26 Exceptions
26.1 C++'s Exception Mechanism
26.2 Example: Exceptions for class Number
26.3 Identifying the Exceptions that you intend to throw
27 Example: Supermarket
27.1 Background and Program Specification
27.2 Design
27.2.1 Design preliminaries
27.2.2 Scenarios: identifying objects, their classes, their responsibilities, their data
27.2.3 Filling out the definitions of the classes for a partial implementation
27.3 A partial implementation
27.4 Finalising the Design
27.4.1 Histograms
27.4.2 Simulating the checkouts and their queues
27.4.3 Organizing the checkouts
28 Design and documentation: 2
28.1 Object-Based Design
28.2 Documenting a design
Part V
29 The Power of Inheritance and Polymorphism
29.1 The "Dungeon" Game
29.2 Design
29.2.1 Preliminaries
29.2.2 WindowRep and Window classes
29.2.3 DungeonItem hierarchy
29.3 An implementation
29.3.1 Windows classes
29.3.2 Class Dungeon
29.3.3 DungeonItems
30 Reusable designs
30.1 The RecordFile Framework: Concepts
30.2 The Framework classes: Overview
30.3 The Command Handler Classes
30.3.1 Class declarations
30.3.2 Interactions
30.3.3 Implementation Code
30.4 Collection Classes and their Adapters
30.5 Class Record
30.6 The Windows Class Hierarchy
30.6.1 Class Responsibilities
30.6.2 Implementation Code
  
Comments (0)