Unformatted text preview:

1 Preamble1.1 Commandments1.2 Style1.2.1 General Rules1.2.2 Naming1.2.3 Usage1.2.4 Indentation1.2.5 Function Definitions1.2.6 Types, type definitions and struct1.2.7 Using the Tools Library2 Issues and Overview2.1 Why did C need a ++?2.1.1 Design Goals for C2.1.2 C++ Extends C.2.1.3 Modeling.2.2 Object Oriented Principles.2.3 Important Differences2.4 Generic Insertion Sort2.4.1 Main Program2.4.2 The DataPack Header File2.4.3 The Data Pack Functions3 C++ I/O for the C Programmer3.1 Familiar Things in a New Language3.2 Include Files3.3 Streams and Files3.3.1 Common Stream Errors, Misconceptions, and Problems3.4 Input3.5 Output3.6 I/O and File Handling Demonstration3.7 End of File and Error Handling3.7.1 Using the command line.3.7.2 Reading Lines of Text3.7.3 EOF and error handling with numeric input.3.8 Assorted short notes.4 An Introduction to Classes4.1 Class Basics4.1.1 Data members.4.1.2 Functions4.2 Inline Functions4.2.1 Code Files and Header Files4.3 Declaration, Implementation, and Application of a Stack Class4.3.1 The Input and Output (banners have been deleted).4.3.2 The main function: main.c and main.cpp4.3.3 The Brackets class.4.3.4 Class Declaration: token.h and token.hpp4.3.5 The Stack Class5 Functions and Parameter Passing5.1 Function Calls5.2 Parameter Passing5.2.1 Three Odd Functions5.2.2 Calling The Odd Functions5.2.3 Parameter Passing Mechanisms5.3 Function Returns5.3.1 L-values and r-values.5.3.2 Using L-values.5.3.3 Using Return Values in Assignment Statements 6 Objects, Allocation, and Disasters6.1 Objects: Static, Automatic, Dynamic, and Mixed6.1.1 Storage Class6.1.2 Assignment and Copying6.2 Static Class Members6.3 Common Kinds of Failure6.4 Causes and Cures6.4.1 A shallow copy disaster.6.4.2 Dangling pointers.6.4.3 Storing things in limbo.6.4.4 The wrong ways to delete.6.4.5 Walking on memory.6.4.6 NULL pointers.7 C++ Bells and Whistles7.1 Optional Parameters7.1.1 A Short Example7.2 Const Qualifiers7.3 Operator Extensions7.3.1 Global Binary Operator Extensions7.3.2 Binary Operator Extensions in a Class.7.3.3 Unary operators.8 Interacting Classes8.1 The Roles of a Class8.1.1 Finding the Classes8.1.2 Diagramming One Class8.2 Class Relationships8.2.1 Composition.8.2.2 Aggregation.8.2.3 Association.8.2.4 Derivation.8.2.5 Friendship.8.2.6 An example.8.2.7 Elementary Design Principles8.3 The Program: Making a Bar Graph8.3.1 Specification8.3.2 The Main Program and Output8.3.3 The Data Structure and UML Diagrams8.3.4 Class Item8.3.5 Class Graph8.3.6 Classes Row and Cell8.4 An Event Trace9 Array Data Structures9.1 Allocation and Deallocation of Arrays.9.2 The Flexible Array Data Structure9.2.1 Implementation in C++9.2.2 Implementation in C9.3 Ragged Arrays9.3.1 Dynamic Ragged Arrays9.4 The StringStore Data Structure9.4.1 The StringStore and Pool Classes.9.5 The StringArray9.6 Hashing9.6.1 The Hash Table Array9.6.2 Hash Functions.9.7 Example: Combining Several Data Structures9.7.1 The Main Program9.7.2 The Dictionary Class9.7.3 The FlexArray and StringStore Classes9.7.4 A Better Way10 Construction and Destruction10.1 New C++ Concepts10.1.1 Talking About Yourself10.1.2 Constructor Initializers10.2 Dynamic Allocation Incurs Overhead.10.2.1 Allocation Example: a Van Containing Boxes10.2.2 How Allocation and Deallocation Work10.3 Construction of C++ Objects10.3.1 A Class Object is Constructed in Layers10.3.2 Layering Demo Program10.4 Constructors and Construction10.4.1 A Variety of Constructors10.5 Destruction Problems11 Modules and Makefiles11.1 Modular Organization and makefiles.11.1.1 History11.1.2 General Concepts11.1.3 Enumerations and External Objects11.1.4 Rules11.2 A Makefile defines the project.11.2.1 Making the Bargraph Application12 Derived Classes12.1 How Derivation is Used12.1.1 Resolving Ambiguous Names12.1.2 Ctor Initializers12.2 Visibility and Protection Level12.2.1 Inherited Functions12.3 Class Derivation Demo12.3.1 Inherited Data Members13 Templates13.1 Basic Template Syntax13.2 A Template for FlexArrays13.3 Adapting a Template13.4 A Precedence Parser: Instantiation of a Template13.4.1 The Operator Class13.4.2 The Main Program13.4.3 UML for Templates13.5 The Standard Template Library13.6 Containers13.7 Iterators13.8 Using Simple STL Classes13.8.1 String13.8.2 Vector13.8.3 Map14 Derivation and Inheritance14.1 Playing 14.1.1 The Hangman Application14.1.2 Hangman: The Main Program14.1.3 Call Graphs14.1.4 UML Diagrams: A View of the Class Relationships14.1.5 The Hangman Data Structures14.2 Hangman: The Game and Board Classes14.2.1 The Game Class14.2.2 The Board Class14.3 The Word Classes14.3.1 The BaseWord Declaration14.3.2 The Derived Word Classes14.4 RandString Adapts a Reusable Data Structure14.4.1 The RandString Declaration15 Polymorphism and Virtual Functions15.1 Basic Concepts15.1.1 Definitions15.1.2 Virtual functions.15.2 Polymorphic Classes15.3 Creating a Polymorphic Container15.3.1 Container: An Abstract Class15.3.2 Linear: A Polymorphic Class15.3.3 Cell: The Helper Class15.3.4 Exam: The Actual Data Class15.3.5 Class diagram.15.4 Stack: Fully Specific15.5 Queue: Fully Specific15.6 A Main Program and its Output16 Abstract Classes and Multiple Inheritance16.1 An Abstract Class Defines Expectations16.2 Abstraction Example: an Ordered Type16.3 Multiple Inheritance16.3.1 Item: The Data Class16.4 Linear Containers You Can Search16.4.1 PQueue: a Sorted Linear Container16.4.2 List: An Unordered Container16.4.3 The Main Program16.5 C++ Has Four Kinds of Casts16.5.1 Static Casts16.5.2 Reinterpret Casts16.5.3 Const Casts16.5.4 Dynamic Casts16.6 Virtual Inheritance and Dynamic Casts16.6.1 Virtual Inheritance16.6.2 Dynamic Casts on the Donut17 Exceptions17.1 Handling Errors in a Program17.1.1 What an Exception Handler Can Do17.2 Defining Exceptions in C++17.2.1 Defining an Exception Type17.2.2 Exception Specifications17.2.3 Playing card demo.17.2.4 Throwing an Exception17.2.5 Catching an Exception17.2.6 Built-in Exceptions17.2.7 Summary18 Design Patterns18.1 Definitions and General OO Principles18.1.1 Definitions18.2 General OO Principles18.3 Patterns18.3.1 GRASP: General Responsibility Assignment Software Patterns 18.4 More Complex Design PatternsExploring C++Alice E. FischerUniversity of New HavenJanuary 2009(Revised to September 1, 2010)Copyrightc2009by Alice E. FischerAll rights reserved. No part of this manuscript may be reproduced, stored in a retrieval system, ortransmitted, in any form or by any means, electronic, mechanical, photocopying,


View Full Document

Yale CPSC 427 - Exploring C++

Pages: 230
Download Exploring C++
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Exploring C++ and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Exploring C++ 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?