Starting Out with C++: Early Objects 9th Edition by Tony Gaddis (eBook PDF)
Starting Out with C++: Early Objects 9th Edition by Tony Gaddis (eBook PDF)
Starting Out with C++: Early Objects 9th Edition by Tony Gaddis (eBook PDF)
Starting Out with C++: Early Objects 9th Edition by Tony Gaddis (eBook PDF)
Starting Out with C++: Early Objects 9th Edition by Tony Gaddis (eBook PDF)
1.
Starting Out withC++: Early Objects 9th Edition
by Tony Gaddis (eBook PDF) pdf download
https://ebooksecure.com/product/starting-out-with-c-early-
objects-9th-edition-by-tony-gaddis-ebook-pdf/
Download more ebook from https://ebooksecure.com
2.
We believe theseproducts will be a great fit for you. Click
the link to download now, or visit ebooksecure.com
to discover even more!
(eBook PDF) Starting Out with Java Early Objects 6th
Edition by Tony Gaddis
http://ebooksecure.com/product/ebook-pdf-starting-out-with-java-
early-objects-6th-edition-by-tony-gaddis/
(eBook PDF) Starting Out with C++: Early Objects 9th
Edition
http://ebooksecure.com/product/ebook-pdf-starting-out-with-c-
early-objects-9th-edition/
Starting out with Visual C# 4th Edition by Tony Gaddis
(eBook PDF)
http://ebooksecure.com/product/starting-out-with-visual-c-4th-
edition-by-tony-gaddis-ebook-pdf/
(eBook PDF) Starting out with Visual C# 4th Edition by
Tony Gaddis
http://ebooksecure.com/product/ebook-pdf-starting-out-with-
visual-c-4th-edition-by-tony-gaddis/
3.
(eBook PDF) StartingOut With Visual Basic 8th Edition
by Tony Gaddis
http://ebooksecure.com/product/ebook-pdf-starting-out-with-
visual-basic-8th-edition-by-tony-gaddis/
(eBook PDF) Starting Out With Visual Basic 7th Edition
by Tony Gaddis
http://ebooksecure.com/product/ebook-pdf-starting-out-with-
visual-basic-7th-edition-by-tony-gaddis/
(eBook PDF) Starting Out with Java: Early Objects 5th
Edition
http://ebooksecure.com/product/ebook-pdf-starting-out-with-java-
early-objects-5th-edition/
(eBook PDF) Starting Out with C++ from Control
Structures to Objects 9th Edition
http://ebooksecure.com/product/ebook-pdf-starting-out-with-c-
from-control-structures-to-objects-9th-edition/
Starting Out With Programming Logic and Design, 6e 6th
Edition Tony Gaddis - eBook PDF
https://ebooksecure.com/download/starting-out-with-programming-
logic-and-design-6e-ebook-pdf/
"
Preface xv
Chapter 1Introduction to Computers and Programming 1
Chapter 2 Introduction to C++ 27
Chapter 3 Expressions and Interactivity 77
Chapter 4 Making Decisions 155
Chapter 5 Looping 243
Chapter 6 Functions 323
Chapter 7 Introduction to Classes and Objects 407
Chapter 8 Arrays 507
Chapter 9 Searching, Sorting , and Algorithm Analysis 603
Chapter 10 Pointers 645
Chapter 11 More about Classes and Object -Oriented Programming 703
Chapter 12 More on ( -Strings and the string Class 815
Chapter 13 Advanced File and 1/ 0 Operations 853
Chapter 14 Recursion 915
Chapter 15 Polymorphism and Virtual Functions 949
Chapter 16 Exceptions, Templates, and the Standard Template Library (STL) 987
Chapter 17 Linked Lists 103 7
Chapter 18 Stacks and Queues 1085
Chapter 19 Binary Trees 1125
Appendix A: The ASCII Character Set 1155
Appendix B: Operator Precedence and Associativity 1159
Appendix C: Answers to Checkpoints 1161
Appendix D: Answers to Odd -Numbered Review Questions 1201
Index 1221
V
Preface xv
CHAPTER 1Introduction to Computers and Programming 1
1.1 Why Program? 1
1.2 Computer Systems: Hardware and Software 3
1.3 Programs and Programming Languages 8
1.4 What Is a Program Made of? 13
1.5 Input, Processing, and Output 17
1.6 The Programming Process 18
1.7 Tying It All Together: Hi! It's Me 23
CHAPTER 2 Introduction to C++ 27
2.1 The Parts of a C++ Program 27
2.2 The cout Object 31
2.3 The# i ncludeDirect ive 36
2.4 Variables and the Assignment Statement 37
2.5 Literals 39
2.6 Identifiers 41
2.7 Integer Data Types 43
2.8 Floating-Point Data Types 48
2.9 The char Data Type 52
2.10 TheC++str i ngClass 56
2.11 The bool Data Type 57
2.12 Determining the Size of a Data Type 58
2.13 More on Variable Assignments and Initialization 59
2.14 Scope 61
2.15 Arithmetic Operators 62
2.16 Comments 66
2.17 Programming Style 67
2.18 Tying It All Together: Smile! 69
vii
8.
viii Contents
CHAPTER 3Expressions and Interactivity 77
3.1 ThecinObject 77
3.2 Mathematical Expressions 84
3.3 Data Type Conversion and Type Casting 92
3.4 Overflow and Underflow 98
3.5
3.6
3.7
3.8
3.9
3.10
Named Constants 99
Multiple and Combined Assignment
Formatting Output 106
Working with Characters and Strings
More Mathematical Library Functions
Random Numbers 132
102
116
130
3.11 Focus on Debugging: Hand Tracing a Program 136
3.12 Green Fields Landscaping Case Study- Part 1 138
3.13 Tying It All Together: Word Game 141
CHAPTER 4 Making Decisions 155
4.1 Relational Operators 155
4.2 The if Statement 161
4.3 Theif/elseStatement 170
4.4 The if /else if Statement 175
4.5 Menu-Driven Programs 183
4.6 Nested i f Statements 185
4.7 Logical Operators 189
4.8 Validating User Input 198
4.9 More about Blocks and Scope 200
4.10 More about Characters and Strings 203
4.11 The Conditional Operator 209
4.12 The switch Statement 213
4.13 Enumerated Data Types 222
4.14 Focus on Testing and Debugging: Validating Output Results 225
4.15 Green Fields Landscaping Case Study- Part 2 227
4.16 Tying It All Together: Fortune Teller 232
CHAPTER 5 Looping 243
5.1 Introduction to Loops: The whi le Loop 243
5.2 Using the while Loop for Input Validation 250
5.3 The Increment and Decrement Operators 253
5.4 Counters 258
5.5 Keeping a Running Total 260
5.6 Sentinels 263
5.7 The do-while Loop 265
9.
5.8 The forLoop 271
5.9 Focus on Software Engineering: Deciding Which Loop to Use 277
5.10 Nested Loops 279
5.11 Breaking Out of a Loop 281
5.12 Using Files for Data Storage 285
5.13 Focus on Testing and Debugging: Creating Good Test Data 301
5.14 Central Mountain Credit Union Case Study 304
5.15 Tying It All Together: What a Colorful World 308
CHAPTER 6 Function s 323
6.1 Modular Programming 323
6.2 Defining and Calling Functions 324
6.3 Function Prototypes 332
6.4 Sending Data into a Function 333
6.5 Passing Data by Value 338
6.6 The return Statement 342
6.7 Returning a Value from a Function 343
6.8 Returning a Boolean Value 349
6.9 Using Functions in a Menu-Driven Program 351
6.10 Local and Global Variables 355
6.11 Static Local Variables 362
6.12 Default Arguments 364
6.13 Using Reference Variables as Parameters 368
6.14 Overloading Functions 378
6.15 The exit() Function 382
6.16 Stubs and Drivers 385
6.17 LittleLottoCaseStudy 387
6.18 Tying It All Together: Glowing Jack-o-lantern 392
CHAPTER 7 Introduction to Classes and Objects 407
7.1 Abstract Data Types 407
7.2 Object-Oriented Programming 409
7.3 Introduction to Classes 411
7.4 Creating and Using Objects 414
7.5 Defining Member Functions 416
7.6 Constructors 423
7.7 Destructors 429
7.8 Private Member Functions 432
7.9 Passing Objects to Functions 435
7.10 Object Composition 442
Contents ix
7.11 Focus on Software Engineering: Separating Class Specification, Implementation ,
and Client Code 446
10.
x Contents
7.12 Structures453
7.13 More about Enumerated Data Types 465
7.14 Home Software Company OOP Case Study 469
7.15 Introduction to Object-Oriented Analysis and
Design 476
7.16 Screen Contro l 486
7.17 Tying It All Together: Yoyo Animation 491
CHAPTER 8 Arrays 507
8.1 Arrays Hold Multiple Values 507
8.2 AccessingArray Elements 509
8.3 Inputting and Displaying Array Data 511
8.4 Array Initialization 518
8.5 The Range-Based for loop 525
8.6 Processing Array Contents 528
8.7 Using Parallel Arrays 539
8.8 The typede f Statement 543
8.9 Arrays as Function Arguments 543
8.10 Two-Dimensional Arrays 553
8.11 Arrays with Three or More Dimensions 560
8.12 Vectors 563
8.13 Arrays of Objects 575
8.14 National Commerce Bank Case Study 585
8.15 Tying It All Together: Rock, Paper, Scissors 587
CHAPTER 9 Searching, Sorting , and Algorithm Analysis 603
9.1 Introduction to Search Algorithms 603
9.2 Searching an Array of Objects 610
9.3 Introduction to Sorting Algorithms 613
9.4 Sorting an Array of Objects 621
9.5 Sorting and Searching Vectors 624
9.6 Introduction to Analysis of Algorithms 627
9.7 Case Studies 635
9.8 Tying It All Together: Secret Messages 635
CHAPTER 10 Pointers 645
10.1 Pointers and the Address Operator 645
10.2 Pointer Variables 647
10.3 The Relationship Between Arrays and
Pointers 651
11.
10.4 Pointer Arithmetic655
10.5 Initializing Pointers 656
10.6 Comparing Pointers 659
10.7 Pointers as Function Parameters 661
10.8 Pointers to Constants and Constant Pointers 665
10.9 Focus on Software Engineering: Dynamic Memory
Allocation 670
10.10 Focus on Software Engineering: Returning Pointers from
Functions 674
10.11 Pointers to Class Objects and Structures 680
10.12 Focus on Software Engineering: Selecting Members
of Objects 684
10.13 Smart Pointers 686
10.14 Tying It All Together: Pardon Me, Do You Have the Time? 694
CHAPTER 11 More about Classesand Object -Oriented Programming 703
11.1 The th is Pointer and Constant Member Functions 703
11.2 Static Members 708
11.3 Friends of Classes 715
11.4 Memberwise Assignment 720
11.5 Copy Constructors 721
11.6 Operator Overloading 730
11.7 Rvalue References and Move Operations 751
11.8 Function Objects and Lambda Expressions 761
11.9 Type Conversion Operators 770
11.10 Convert Constructors 773
11.11 Aggregation and Composition 776
11.12 Inheritance 782
11.13 Protected Members and Class Access 787
11.14 Constructors, Destructors, and Inheritance 792
11.15 Overriding Base Class Functions 797
11.16 Tying It All Together: Putting Data on the World Wide Web 800
CHAPTER 12 More on C-Strings and the s t ring Class 815
12.1 C-Strings 815
12.2 Library Functions for Working with C-Strings 820
12.3 Conversions Between Numbers and Strings 829
12.4 Writing Your Own C-String Handling Functions 833
12.5 More about the C++ str i ng Class 839
12.6 Advanced Software Enterprises Case Study 842
12.7 Tying It All Together: Program Execution Environments 844
Contents xi
12.
xii Contents
CHAPTER13 AdvancedFile and 1/ 0 Operations 853
13.1 Input and Output Streams 853
13.2 More Detailed Error Testing 861
13.3 Member Functions for Reading and Writing Files 865
13.4 Binary Files 877
13.5 Creating Records with Structures 881
13.6 Random -Access Files 886
13.7 Opening a File for Both Input and Output 893
13.8 Online Friendship Connections Case Study: Object Serialization 898
13.9 Tying It All Together: File Merging and Color-Coded HTML 903
CHAPTER14 Recursion 915
14.1 Introduction to Recursion 915
14.2 The Recursive Factorial Function 922
14.3 The Recursive gcd Function 924
14.4 Solving Recursively Defined Problems 925
14.5 A Recursive Binary Search Function 927
14.6 Focus on Problem Solving and Program Design: The QuickSort Algorithm 929
14.7 The Towersof Hanoi 933
14.8 Focus on Problem Solving: Exhaustive and Enumeration Algorithms 936
14.9 Focus on Software Engineering: Recursion versus Iteration 940
14.10 Tying It All Together: Infix and Prefix Expressions 941
CHAPTER15 Polymorphism and Virtual Functions 949
15.1 Type Compatibi lity in Inheritance Hierarchies 949
15.2 Polymorp hism and Virtual Member Functions 955
15.3 Abstract Base Classes and Pure Virtual Functions 963
15.4 Focus on Object-Oriented Programming : Composition versus Inheritance 969
15.5 Secure Encryption Systems, Inc., Case Study 973
15.6 Tying It All Together: Let's Move It 976
CHAPTER16 Exceptions, Templates, and the Standard Template Library
(STL) 987
16.1 Exceptions 987
16.2 Function Templates 999
16.3 Class Templates 1007
16.4 Class Templates and Inheritance 1012
16.5 Introduction to the Standard Template Library 1016
16.6 Tying It All Together: Word Transformers Game 1029
13.
CHAPTER 17 LinkedLists 1037
17.1 Introduction to the Linked List ADT 1037
17.2 Linked List Operations 1043
17.3 A Linked List Template 1055
17.4 Recursive Linked List Operations 1059
17.5 Variations of the Linked List 1067
17.6 The STL list Container 1068
17.7 Reliable Software Systems, Inc., Case Study 1071
17.8 Tying It All Together: More on Graphics and Animation 1074
CHAPTER 18 Stacks and Queues 1085
18.1 Introduction to the Stack ADT 1085
18.2 Dynamic Stacks 1093
18.3 The STL stack Container 1097
18.4 Introduction to the Queue ADT 1099
18.5 Dynamic Queues 1106
18.6 The STL deque and queue Containers 1109
18.7
18.8
Focus on Problem Solving and Program Design: Eliminating Recursion
Tying It All Together: Converting Postfix Expressions to Infix 1117
CHAPTER 19 Binary Trees 1125
19.1 Definition and Applications of Binary Trees 1125
19.2 Binary Search Tree Operations 1129
19.3 Template Considerations for Binary Search Trees 1145
19.4 Tying It All Together: Genealogy Trees 1145
Appendix A: The ASCII Character Set 1155
Appendix B: Operator Precedence and Associativity 1159
Appendix C: Answers to Checkpoints 1161
Contents xiii
1112
Appendix D: Answers to Odd -Numbered Review Questions 1201
Index 1221
14.
xi v Contents
AdditionalAppendices
The following append ices are located on the book's companion web site.
Appendix E: A Brief Introduction to Object -Oriented Programming
Appendix F: Using UMLin Class Design
Appendix G: Multi-Source File Programs
Appendix H: Multiple and Virtual Inheritance
Appendix I: Header File and Library Function Reference
Appendix J: Namespaces
Appendix K: C++ Casts and Run-Time Type Identification
Appendix L: Passing Command Line Arguments
Appendix M: Binary Numbers and Bitwise Operations
Appendix N: Introduction to Flowcharting
15.
Welcome to StartingOut with C++:Early Objects, 9th Edition. This book is intended
for use in a two -term or three-term C++ programming sequence, or an accelerated
one-term course. Students new to programming, as well as those with prior course work
in other languages, will find this text beneficial. The fundamentals of programming
are covered for the novice, while the details, pitfalls, and nuances of the C++ language
are explored in-depth for both the beginner and more experienced student . The book
is written with clear, easy-to -understand language and it covers all the necessary
topics for an introductory programming course. This text is rich in example programs
that are concise, practica l, and real world oriented, ensuring that the student not only
learns how to implement the features and constructs of C++, but why and when to
use them.
What's New in the Ninth Edition
The New C++11 Standard
C++11 is the latest standard version of the C++ language. In previous years, while the
standard was being developed, it was known as C++Ox. In August 2011, it was
approved by the International Standards Organization (ISO), and the name of the
standard was officially changed to C++l l. Most of the popular C++ compilers now
support this standard.
The new C++11 standard was the primary motivat ion behind this edition, which
introduces many of the new language features. However, a C++11 compi ler is not
strictly required to use the book . As you progress through the book, you will see
C++ll icons in the margins, next to the new features that are introduced . Programs
appearing in sections that are not marked with this icon will still compi le using an
older compiler.
The C++11 Topics Introduced in This Edition
• The aut o key word is introduced in Chapter 2 as a way to simplify comp lex
variable definitions. This key word causes the compiler to infer a variable's data
type from its initialization value.
xv
16.
xvi Preface
• Chapter2 also introduces the new long long i nt and unsigned long long i nt
data types and the LL literal suffix.
• Chapter 5 shows how to pass a str i ng object directly to a file stream object's
open member function, without the need to call the c_st r () member function.
A discussion of the c_st r () function sti ll exists for anyone using a legacy
compiler.
• Th e range -based for loop is introduced in Chapter 7. Thi s new looping
mechanism automatically iterates over each element of an array, vector, or
other collection, without the need for a counter variable or a subscript.
• Chapter 7 also introduces strongly typed enums
.
• Chapter 8 introduces new ways to initialize variables and shows how a vect or
can now be initialized with an initialization list.
• Chapter 10 introduces smart pointers and provides examples of how and why to use
the new uni que_ptr and shared_ptr pointers for safely allocating and working
with dynamic memory.
• Chapter 10 also introduces the move assignment operator, and the null pt r key
word, which is now the standard way of representing a null pointer.
• Chapter 11 discusses move constructors, provides more in depth coverage of
move assignment operators, and introduces lambda expressions .
• Chapter 12 introduces new functions in the C++11 string library and discusses
the new overloaded to _stri ng functions for convert ing numeric values to stri ng
objects.
• Chapter 15 introduces and demonstrates the use of the new override key word
that helps prevent subtle overridin g errors and the new final key word that
prevents a virtua l member function from being overridden .
• Chapter 16 introduces the new C++11 functions begi n(c) and end (c) to specify
positions within a collection c where an operat ion should begin and end.
What Else is New
This book's pedagogy and clear writing style remain the same as in the previous edition.
However, in addition to updating the book to introduce the new C++l 1 standard,
many improvements have been made to make it even more student -friendly.
• Upd ated Material
Material has been updated throughout the book to reflect changes in technology
and in software development environments, as well as to improve clarity and
incorporate best practices in teaching introductory programming . As a result,
new graphics and new or redesigned figures have been added throughout the
book where appropriate and new or impr oved sample programs have been
included in a number of chapters .
• New Material
New materia l has been added on a number of topics. In addition to introducing
and using new C++11 features, this new edition includes new sections on literals,
random numbers, and enumerated data types, as well as improved materia l on
designing classes.
17.
Preface xvii
• NewProgramming Challenges
New Programming Challenge problems have been added to every chapter.
• Reorganized Chapters
Several chapters have been redesigned to improve student learning . Chapter 5
(Looping) has been reorganized to give students more practice using the whi le
loop before introducing do-while and for loops. The Chapter 6 (Functions)
material on defining and calling functions has been reorganized to introduce
function prototypes earl ier and allow main to always be the first function in
a client program .
Organization of the Text
This text teaches C++ in a step-by-step fashion. Each chapte r covers a major set of
topics and builds knowledge as the student progresses through the book . Although
the chapters can be easily taught in their existing sequence, flexibility is provided .
The following dependency diagram (Figur e P-1) suggests possible sequences of
instruct ion.
Chapter 1 covers fundamental hardware, software, and programm ing concepts. The
instructor may choose to skip this chapter if the class has already mastered those topics.
Chapters 2 through 6 cover basic C++ syntax, data types, expressions, selection
structures, repetition structures, and functions . Each of these chapters builds on the
previous chapter and should be covered in the order presented.
Chapter 7 introduces object-oriented programming . It can be covered any time after
Chapter 6, but before Chapter 11. Instructors who prefer to introduce arrays before
classes can cover Chapter 8 before Chapter 7. In this case it is only necessary to
postpone Section 8.13 (Arrays of Objects) until Chapter 7 has been covered.
As Figure P-1 illustrates, in the second half of the book Chapters 11, 12, 13, and 14
can be covered in any order. Chapters 11, 15, and 16, however, should be done in
sequence. Instructors who wish to introduce data structures at an earlier point in the
course, without having first covered advanced C++ and OO P features, can cover
Chapter 17 (Linked Lists), followed by Chapters 18 and 19 (Stacks & Queues and
Binary Tr ees), any time after Chapter 14 (Recursion). In this case it is necessary to
simply omit the sections in Chapters 17- 19 that deal with templates and the Standard
Template Library.
18.
xviii Preface
Figure P-1
Chapter1
Introduction
..
Chapters2-6
Basic
Language
Elements
I
••
Chapter7 Chapter8
OOPIntroduc
tion Arrays
I
+ +
Chapter9
Chapter10
Search
ing, Sorting
,
Pointers
andAlgorithm
Analys
is
I
I
+ • + •
Chapter12 Chapter13
Chapter14
Chapter11
Advanced AdvancedFiles
Recursion
MoreOOP
Strings and1/0
• •
Chapter15 Chapter17
Adv.OOP LinkedLists
I
• + +
Chapter16
Chapter18
Chapter19
Except
ions,
Stacksand
BinaryTrees
Templates
,
Queues
andSTL
19.
Preface xix
Brief Overviewof Each Chapter
Chapter 1: Introduction to Computers and Programming
This chapter provides an introduction to the field of computer science and covers
the fundamentals of hardware , software, operating systems, programming, problem
solving, and software engineering . The components of programs, such as key words,
variables, operators, and punctuation are covered . The tools of the trade , such as
hierarchy charts and pseudocode, are also presented . The Tying It All Together
sect ion shows students how to use the cout statement to create a personalized
output message. Programm ing Challenges at the end of the chapter help students see
how the same basic input, processing , and output structure can be used to create
multiple programs .
Chapter 2: Introduction to C++
This chapter gets the student started in C++ by introducing the basic parts of a
C++ program , data types, the use of variables and literals, assignment statements,
simple arithmetic operations, program output, and comments . The C++ st ring
class is presented and string objects are used from this point on in the book as
the primary method of handling strings. Programm ing style conventions are
introduced , and good programming style is modeled here, as it is throughout the
text . The Tying It All Toget her section lets the student play with simple text -
based graphics.
Chapter 3: Expressions and Interactivity
In this chapter the student learns to write programs that input and handle numer ic,
character, and string data. The use of arithmet ic operators and the creation of
mathemat ical expressions are covered, with emphasis on operator precedence .
Debugging is introduced, with a section on hand tracing a program . Sections are also
included on using random numbers , on simple output formatting, on data type
conversion and type casting, and on using library functions that work with numbers.
The Tying It All Together section shows students how to create a simple interactive
word game.
Chapter 4: Making Decisions
Here the student learns about relational expressions and how to control the flow of a
program with if, if I else , and if I else i f statements . Logical operators, the
conditional operator, and the swi tch statement are also covered. Applications of these
constructs, such as menu-driven programs , are illustrated . This chapter also introduces
the concepts of blocks and scope and continues the theme of debugging with a section
on validating output results. The Tying It All Together section uses random numbers
and branching statements to create a fortune telling game.
20.
xx Preface
Chapter 5:Looping
This chapter introduces, C++'s repetitive control mechanisms .The while loop, do-while
loop, and for loop are presented, along with a variety of methods to control them. These
include using counters, user input, end sentinels, and end-of-file testing. Applications
utilizing loops, such as keeping a running total and performing data validation, are also
covered . The chapter includes an extensive section on working with files and a section
on creating good test data, continuing the book's emphasis on testing and debugging.
The Tying It All Together section introduces students to Windows commands to create
colorful output and uses a loop to create a multi-colored display.
Chapter 6: Functions
In this chapter the student learns how and why to modularize programs, using both
void and value-returning functions. Parameter passing is covered, with emphasis on
when arguments shou ld be passed by value versus when they need to be passed by
reference. Scope of variables is covered and sections are provided on local versus global
variables and on static local variables . Overloaded functions are also introduced and
demonstrated . The Tying It All Together section includes a modular, menu -driven
program that emphasizes the versatility of functions, illustrating how their behavior
can be controlled by the arguments sent to them .
Chapter 7: Introduction to Classes and Objects
In this chapter the text beginsto focus on the object-oriented paradigm. Students have used
provided C++ classessince the beginning of the text, but now they learn how to define their
own classes and to create and use objects of these classes. Careful attention is paid to
illustrating which functions belong in a class versus which functions belong in a client
program that usesthe class.Good object-oriented practicesare discussedand modeled, such
as protecting member data through carefully constructed accessor and mutator functions
and hidingclassimplementation detailsfrom client programs. Once students are comfortable
working with classes and objects, the chapter provides a brief introduction to the topic of
object-oriented analysis and design. The chapter also includesa section on enumerated data
types and a section on structures, which are used in the Tying It All Together section, where
students learn to use screencontrol techniques to create a yoyo animation.
Chapter 8: Arrays
In this chapter the student learns to create and work with single and multidimensional
arrays. Many examples of array processing are provided, including functions to compute
the sum, average, highest and lowest values in an array. Students also learn to create tables
usingtwo-dimensional arrays, and to analyzearray data byrow or bycolumn.Programming
techniques using parallel arrays are also demonsrrated, and the student is shown how to
use a data file as an input source to populate an array . The range-based for loop is
introduced as an easy way to iterate through all the elements of an array, and STL vectors
are introduced and compared to arrays. A section on arrays of objects and structures is
located at the end of the chapter, so it can be covered now or saved for later ifthe instructor
wishes to cover this chapter before Chapter 7. The Tying It All Together section uses
arrays to create a game of Rock, Paper,Scissorsbetween a human playerand the computer.
21.
Preface xxi
Chapter 9:Searching, Sorting, and Algorithm Analysis
Here the student learns the basics of searching for information stored in arrays and of
sorting arrays, including arrays of objects. The chapter covers the Linear Search, Binary
Search, Bubble Sort, and Selection Sort algorithm s and has an optional section on
sortin g and search ing STL vectors. A brief introd uction to algorithm analysis is
included, and students are shown how to determine which of two algorithms is more
efficient. This chapter's Tying It All Together section uses both a table lookup and a
searching algorithm to encode and decode secret messages.
Chapter 10: Pointers
Thi s chapter explains how to use pointers . Topics include pointer arithmetic,
initialization of pointers , comparison of pointers, pointers and arrays, pointers
and funct ions, dynamic memory allocation , the new null pt r key word, and
more . A new section introduces smart pointers and shows how they can be used
to avoid memory leaks. The Tying It All Toget her section demonstrates the use of
pointers to access library data struct ures and functions that return calendar and
wall clock time.
Chapter 11: More About Classes and Object -Oriented Programming
This chapter contin ues the study of classes and object-oriented programming, covering
more advanced topics such as inheritance and object aggregat ion and compos ition.
Other topics include constant member functions, static members, friends, memberwise
assignment, copy constructors, object type conversion operators, convert constr uctors,
operator overloading, move constr uctors, and move assignment operators . A new
section introduces function objects and the C++ll lambda expressions. The Tying It
All Together section brings together the concepts ofinheritance and convert constr uctors
to build a program that formats the contents of an array to form an HTML table for
display on a Web site.
Chapter 12: More on (-Strings and the string Class
This chapter covers standard library functions for working with characters and
C-strings, as well as materia l on str i ng class functions, functions in the new C++11
string library, and new overloaded to_st ring functions for converting numeric
values to str i ng objects . The Tying It All Together section shows students how to
access string-based program environments to obtain information about the computer
and the network on which the program is running.
Chapter 13: Advanced File and 1/ 0 Operations
Thi s chapte r intr oduces more advanced topics for work ing with sequential access
text files and introduces random access and binary files. Various modes for open -
ing files are discussed, as well as the many methods for reading and writing their
contents. Th e Tying It All Toget her program app lies many of the techniques
covered in the chapte r to merge two text files into an HTML doc ument for display
on the Web, with different colors used to illustrate which file each piece of data
came from .
22.
xxii Preface
Chapter 14:Recursion
In this chapter recursion is defined and demonstrated . A visual trace of recursive calls
is provided, and recursive applications are discussed. Many recursive algorithms are
presented, including recursive functions for computing factorials, finding a greatest
common denominator (GCD), performing a binary search, sorting using QuickSort,
and solving the famous Towers of Hanoi problem . For students who need more
challenge, there is a section on exhaustive and enumeration algorithms. The Tying It
All Together section uses recursion to evaluate prefix expressions .
Chapter 15: Polymorphism and Virtual Functions
The study of classes and object-oriented programming continues in this chapter with
the introduction of more advanced concepts such as polymorphism and virtual
functions. Information is also presented on abstract base classes, pure virtual functions,
type compatibi lity within an inheritance hierarchy, and virtual inheritance. The Tying
It All Together section illustrates the use of inheritance and polymorphism to display
and animate graphica l images.
Chapter 16: Exceptions, Templates, and the Standard Template
Library (STL)
Here the student learns to develop enhanced error trapping techniques using exceptions.
Discussion then turns to using function and class templates to create generic code.
Finally, the student is introduced to the containers, iterators, and algorithms offered by
the Standard Template Library (STL). The Tying It All Together section uses various
conta iners in the Standard Template Librar y to create an educational children's game.
Chapter 17: Linked Lists
This chapter introduces concepts and techniques needed to work with lists. A linked list
ADT is developed,and the student learns how to create and destroy a list,as wellas to write
functionsto insert, append, and deletenodes, to traversethe list,and to search for a specific
node. A linked list class template is also demonstrated. The Tying It All Together section
brings together many of the most important concepts of OOP by using objeets,inheritance,
and polymorphism in conjunction with the STLlistclassto animate a collection of images.
Chapter 18: Stacks and Queues
In this chapter the student learns to create and use static and dynamic stacks and queues.
The operations of stacks and queues are defined, and templates for each ADT are
demonstrated . The stat ic array -based stack uses exception -handling to handle stack
overflow and underflow, providing a realisticand natural example of defining, throwing,
and catching except ions . The Tying It All Together section discusses strateg ies for
evaluating postfix expressions and uses a stack to convert a postfix expression to infix.
Chapter 19: Binary Trees
This chapter covers the binary tree ADT and demonstrates many binary tree operat ions.
The student learns to traverse a tree, insert, delete, and replace elements, search for a
particular element, and destroy a tree. The Tying It All Together section introduces a
tree structure versatile enough to create genealogy trees.
"'I must nowgo back to tell some other events which had
occurred. Like most young men of my day, I had been somewhat
extravagant, and had lived a good deal beyond the income which my
father allowed me. My debts amounted to between nine and ten
thousand pounds when I first met with poor Mary Graves. My
creditors were importunate; I had not the means of paying them;
and, about seven months after my marriage, one of them applied to
my father. He sent for me, and sternly demanded that I should give
him an account of everything I owed. I did so; and, to my surprise, I
found him much less enraged than I could have imagined. But it
soon appeared that he had a project in his head which would compel
me to disobey and offend him. He asked me if I had ever seen a
young lady whom he named--in short, your own dear mother. I told
him I had not, but that I had always heard her highly spoken of. He
then informed me that he was acquainted with her father, and that,
as she was an only child and heiress of considerable wealth, he had
proposed to him a marriage between her and me. Your maternal
grandfather had consented, upon the condition that the marriage
should be agreeable to ourselves; and my father now said, "On
condition of your marrying this young lady, I will at once pay your
debts and settle a larger income upon you." I cannot minutely
describe the scene that ensued. Of course, I was obliged to refuse;
and I did so decidedly and at once. That was sufficient to excite
great wrath; but my father smothered it in a degree, and requested
me at least to see the young lady before I decided. I endeavoured,
as humbly as I could, to represent to him that, by pursuing such a
course, and then refusing to marry her, especially after what had
taken place between him and her father, I should be grossly
wronging and insulting her. But now the storm broke forth. He told
me that a rumour had reached him, that I was either keeping or had
married some low woman; that he had refused to believe such an
assertion; but that my conduct gave such strong confirmation to the
report that he would take means to ascertain, the fact; and if he
found I had been guilty of so base a dereliction of my duty to him,
and of my rank and station in society, he would cast me off for ever;
would bequeath every farthing of the property which he could
25.
alienate--and that wasnearly the whole--to strangers, and leave me
what he justly called that most miserable of wretches, a titled
beggar. He would not hear me utter a word, but drove me forth from
his presence to seek comfort with my poor wife, from whom I was
obliged to conceal the sorrows which my marriage with her had
brought upon me.
"'Thus matters continued till her death--knowing that I was
watched, and obliged to have recourse to a thousand stratagems to
conceal my movements. Even after the poor girl's death, I knew my
father too well to doubt that, if he discovered I had a son by such a
marriage, he would carry his threat into execution; and in my
difficulty and distress I applied to my friend Hayley, made him my
confidant, and induced him to promise that he would acknowledge
the child as his own and superintend his education, till such time as I
should be enabled publicly to declare my marriage.
"'Some months after, I accidentally met with your mother in
society, found her beautiful, amiable, and in every respect agreeable
to me, and I took means to make myself agreeable to her. She was
quite unconscious of what had previously taken place, and gave
such encouragement as no well-educated woman would afford to a
man whom she would afterwards reject. Her father, however, who
was well aware of the whole, at first treated me very coldly; but as
soon as I had made up my mind to offer her my hand, I thought it
right to have an explanation with him; and I pointed out to him that
I had acted honourably towards his daughter, in refusing to be
introduced to her with such views, unless I were positively
determined to carry them out. I soon overcame all his prejudices. He
became attached to me. His daughter accepted my offered hand;
and I wrote to my father, whom I had not seen for some months,
hoping that my obedience, tardy as it was, would be accepted. He
was not fond of writing, and he sent for me to come to him. When I
went, my treatment was that which might have been shown towards
a very lowly dependant. He told me that, if I wished to show myself
dutiful, my submission came too late; that now I might marry your
26.
mother or not,as I pleased; that he approved of the match, but did
not require it; and that, although he would allow me an income
equal to my station and expectations, he would settle nothing upon
me. He added, in a low but very menacing tone, "I have my doubts,
young man--I have my doubts; and if ever I find that you have
degraded your name or rank, I will leave you without one penny of
which I can deprive you."
"'I was obliged to bear these tidings to my future father-in-law;
but, with a certain portion of ambition, he was a kind-hearted and
affectionate man. He knew that his daughter loved me. He felt
confident, from all he had seen, that I loved her, and his consent to
our marriage was given--unwillingly, indeed, for he was sufficiently
wealthy to look high for a match for his daughter, and to desire a
settlement proportionate to her fortune. However, all objections
were waived, and we were married. My allowance from my father
was liberal. Her fortune was large, and eight months after, it was
trebled by the death of her father. All that I possessed, however, and
all that I should ever possess, except a very small portion, depended
upon the earl's never discovering that I had contracted a previous
marriage, and had had a son by a plebeian wife. My dear boy
therefore remained under the care of Mr. Hayley, was brought home
by him while yet almost an infant, acknowledged as his son,
educated with great care, and displayed in person and mind, in
character and demeanour----'
"But I need not read all that," said Henry. "After a few
commendations on my boyhood, the letter goes on thus:--
"'You have seen him often, my dear Anne. You know him well, for
I brought him up with you almost as a brother, intending to tell you
that he actually was so, before you reached the age of womanhood.
I loved him--oh, how dearly and how well! And you loved him too, I
am sure, with that fraternal love which was exactly what I desired.
No act, no thought, of his ever gave me a moment's pain; and
27.
without wishing formy own father's death, I longed to be able to tell
you and your mother that this boy was my son.
"'At length I was suddenly summoned away to Belford, to attend
upon my father, who had been seized with severe illness. I could
have wished to remain in London or in its neighbourhood, for I knew
that the affairs of Mr. Hayley were getting into sad disorder. I had
already supplied him, more than once, with considerable sums of
money, beyond the expenses of my dear boy's education and
maintenance; and a new demand had been made upon my purse,
accompanied by a vague and timid threat.
"'However, I was obliged to set out. My father died a week or two
after; and I proceeded from Milford Castle to Caermarthen, to
consign his remains to the family vault. On my way back, my
carriage was overturned at the bridge at ----, and I was taken up
insensible, with concussion of the brain. I remained ill for several
weeks, and my recovery was slow and difficult. For a long time the
medical men would not suffer me to read or write at all; but at
length, one morning, after I had been permitted to go out once or
twice, I took up the newspaper on the breakfast-table, and was
struck with horror and dismay on reading a paragraph headed, "The
Late Forgery." I cannot dwell on the particulars even now, my dear
child. Suffice it to say, that that paragraph showed me that my son,
your dear brother, had been accused of forgery to a large amount;
that he had fled from the country, after having been traced down to
Northumberland, and thence to Caermarthen, in search of me, it
seems; and that the officer who had followed him to Ancona had
there, by the monks, been shown a dead body which they solemnly
declared to be his. My feelings were almost those of a madman. I
knew my boy was not guilty. I saw it all in a moment: that Hayley, a
bankrupt gambler as he had proved, had committed the forgery, and
had induced the boy, who thought him his father, to fly, in order to
screen his supposed parent. At the same time, a vague, wild hope--
which haunts me yet--that my child might still be alive, that the
officer might have been deceived by a pious fraud of the monks--
28.
took possession ofmy mind, and made me act upon the moment
with a degree of fierceness and resolution which perhaps I might not
have had the courage to display if I had paused to deliberate. I sent
for the man Hayley, with a threat that if he did not come I would
fetch him; and when he appeared before me, all pale and trembling,
I accused him at once of what he had done, as if I had had a
revelation of the whole facts. He was always a coward, and in his
attempts to deny and equivocate he betrayed himself; but I wrung
the whole from him, as if I had taken his false heart in my hand and
crushed out the only drops of truth it contained. I told him that if he
did not instantly, and at once, confess the whole, I would carry him
from my house to the office of the magistrate; that I would prove,
from his own letters to me, that he was a bankrupt and a beggar but
a few days before that forgery was committed; that I would make
him account for the possession of every penny which he had
expended since, and leave the keen hounds of justice to follow out
the scent. He did at length confess the whole, and put it down in
writing, signing it in my presence and that of Alsager, the butler,
upon the condition that I would not reveal the facts till after his
death, unless my boy ever appeared in England again.
"'My hopes of such being the case have daily decreased, but they
linger still. I have caused many inquiries to be made, and secret
investigations to be carried on; but the only fact I have been able to
discover, which keeps expectation alive, is that there were two lads,
nearly of the same age, in the convent, at the time my poor boy was
supposed to nave died at Ancona. In case he should appear again,
before you arrive at the age of one-and-twenty, I have besought my
dear old friend Charles Hargrave, of Detchton-Grieve, near Belford,
to watch carefully the events that take place in London; and if Henry
should come back, to desire you to open this letter at once. The
confession of Hayley, with several other papers concerning my
private marriage and the boy's birth and education, are in an ebony
cabinet in my dressing-room at Milford Castle. It is sealed up, with
an order written upon it, to the effect that it is only to be opened by
yourself, after you have reached the age of one-and-twenty.
29.
"'And now, mydear child, farewell. These lines will not meet your
eyes till your father's are closed. I know I have no need to exhort
you to do justice to your brother, if ever you should find him; and if
you should not, to clear his memory, after Mr. Hayley's death. Your
mother's ample fortune will be sufficient provision for you, and the
estates of the family will descend to you, without being specially
mentioned in my will; but remember that you hold them in trust for
him, if ever he should reappear. Should such be the case, I trust that
the affection which existed between you and him, as boy and girl,
may be a blessing to you both in more mature years. And now, that
heaven may protect you, and send you a happier fate than mine, is
the sincerest prayer of
"'Your father,
"'Milford.'"
Henry's voice faltered as he read the latter sentences of his
father's letter to his sister, and there were tears in Lady Anne's
bright eyes; but those tears did not run over till old Mr. Hargrave laid
his hand upon hers, saying--
"Well and nobly, my dear child, have you fulfilled your excellent
father's last behest, and justified his judgment both of head and
heart."
"And I am a proud man," said Mr. Winkworth, looking at her
through his spectacles, which he had been wiping more than once,
for some reason or another; "for I shall one day call her child who
has so brightly performed her duty to a dead father and a living
brother."
"Hush, hush, hush!" exclaimed Lady Anne, starting up: "you will
drive me away. Did you not promise, most faithless of Indians? You
are as bad as the man in the fairy tale."
30.
"And as ugly,"replied Mr. Winkworth, laughing; "but I fear, dear
lady, I shall never find a kind girl to restore me to my pristine form
again--though, if there be a sorceress upon earth who could do it,
she were Anne Mellent. Pray use your interest with her for me, my
dear lord, for I would fain have youth and beauty back, as they
appeared before they had been taken away by that fell enchanter,
Time; and here are two people in the room--my old acquaintance
Hargrave and my dear sister Lady Fleetwood--who can tell you that I
was a very good-looking fellow nine-and-twenty years ago, when I
was called Charles Marston."
"Charles Marston!" exclaimed Lady Fleetwood, almost with a
scream. "You Charles Marston!"
"Yes, my dear Meg," replied Mr. Winkworth; "even your poor
brother-in-law."
"But, dear me!" cried Lady Fleetwood, "Scriven told me you were
a bankrupt, and Charles says you are very rich."
"Both, Meg--both," replied Mr. Winkworth. "There Scriven told
truth, and Charles too. Do you not know that I never did things like
other men? and when I was coming from India, as there were some
dear friends who owed me a couple of lacs, and were too
gentlemanly to pay an old friend, I made myself a bankrupt, that the
task of suing them might fall upon my assignees. I had the hint, by-
the-way, from Grange, the pastry-cook, who made himself a
bankrupt every year, just to call in his accounts; but I rather think I
am capable of paying a hundred shillings in the pound; and now all I
have to say is--and I say it deliberately before witnesses--if Lady
Anne Mellent will condescend to take up with a merchant, and does
not object to old age, and is very fond of a yellowish skin and a lean
person, I am ready to marry her as soon as this wound in my
shoulder is quite well; and I will settle a quarter of a million upon
her on her wedding-day, whether she marries me or----Well, well,
my dear; I won't."
31.
So complete wasthe surprise of all present, except Mr. Hargrave
and Lady Anne, that there was a dead silence for half-a-minute; and
then Lady Fleetwood, whose wit always fixed upon something
collateral, asked aloud--
"What are lacs?"
A burst of laughter followed, and perhaps it was the best way of
ending the explanation.
Lady Anne made good her retreat as fast as possible; and after
the gentlemen were left together, Henry laid before Mr. Hargrave
and the rest all the papers which went to prove his title--Lord
Milford's account of his private marriage, in a more detailed form
than he had given it to his daughter; the documents with which he
had been furnished by the monks at Ancona, to prove that he was
Henry Hayley, notwithstanding his long assumption of the name of
Middleton; some letters upon the subject from Don Balthazar de
Xamorça; and, last, the certificate of the marriage of Charles Mellent
and Mary Graves, and that of his own birth.
"For these latter papers," he said, "I am indebted to the activity
and intelligence of that worthy man, Joshua Brown; and by your
permission, gentlemen, I will have him in, and thank him, in your
presence, for all he has done for me."
The pedlar was soon introduced, and in graceful terms the young
nobleman expressed his gratitude, making him sit down beside him.
"There is a lady," said Henry, "who longs much to thank you, Mr.
Brown, and to-morrow, before breakfast, you must let me introduce
you to her. Will you take a glass of wine to drink her health?"
"Willingly, my lord," replied the pedlar, "for my lord you are; but
yet I think you will find a little hitch somewhere that will want
making smooth."
32.
"In good truth,my dear young friend, he is right," said Mr.
Hargrave, who had been looking carefully over the papers. "Here is
every proof that you passed as Henry Hayley; every proof that
Milford was privately married and had a son; every proof that he
believed you to be that son, and that Hayley told him so; but no
legal proof whatever that the boy who was given to the care of the
nurse by your poor father was the same that Mr. Hayley brought
home and acknowledged as his own."
"I've got it here, sir," said the pedlar, producing an old pocket-
book. "I told the young lord that he'd want more of my help; so,
between the time when I last saw him and the day I went to listen
at Lady Fleetwood's, I ran down to the part of the country where
they were married; for I recollected quite well having seen a pretty
babby, about that time, at Mrs. Goldie's, the grocer's widow's, with
black ribbons upon its little white frock; and I knew it was a nurse-
child, for she had none of her own--never had. She's alive to this
day; and there is her certificate that the child she delivered to
Stephen Hayley, Esq. was the child of Charles Mellent and Mary
Graves. She has got, moreover, the order, in Charles Mellent's own
hand, to deliver the child to Mr. Hayley, and Mr. Hayley's
acknowledgment that he had received it. She says, too, that with the
child she gave him a gold box, the top of which unscrews, and in it
she put a paper, like a careful old body as she is, with all the marks
the child had upon it, such as moles and spots, and such like, which
most of us have more or less."
"I've got the box!" cried Mr. Winkworth, alias Marston, who had
broken off a conversation with his son to listen: "I owe that to the
care of my little man Jim. It was found in the goods and chattels of
poor Miss Hayley; but there is amongst her papers a memorandum,
written in one of her saner moods, stating that the box was brought
with the clothes of her brother's son, Henry Hayley, when he first
came home from the place where he was nursed, and that she
always preserved it carefully, in the hope that she might some time
33.
hear news ofthe poor child's mother, who must have been of some
rank, as there is a coronet engraved upon the box."
"Bravo! bravo!" said Mr. Hargrave: "the only link wanting in the
chain seems to be supplied; and now I think we shall do, without
any further question."
And so think I, dear reader, too.
FOOTNOTES
Footnote 1: It may be as well to state, that this story of Carlo Carlini
was told to the author, word for word, as it is here written
down, by Carlo Carlini himself, then the author's servant. I
cannot forbear adding, that a more faithful, honest, intelligent
man never lived; and that, after having left my service, on my
return to England, he entered that of my friend, the late Mr.
Scott, Consul-General at Bordeaux, where he gained the
esteem of all, and died, I believe, in the arms of his young
master, the present Mr. Scott.
THE END.
34.
*** END OFTHE PROJECT GUTENBERG EBOOK THE FORGERY; OR,
BEST INTENTIONS. ***
Updated editions will replace the previous one—the old editions will
be renamed.
Creating the works from print editions not protected by U.S.
copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying
copyright royalties. Special rules, set forth in the General Terms of
Use part of this license, apply to copying and distributing Project
Gutenberg™ electronic works to protect the PROJECT GUTENBERG™
concept and trademark. Project Gutenberg is a registered trademark,
and may not be used if you charge for an eBook, except by following
the terms of the trademark license, including paying royalties for use
of the Project Gutenberg trademark. If you do not charge anything
for copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.
START: FULL LICENSE
PLEASE READ THISBEFORE YOU DISTRIBUTE OR USE THIS WORK
To protect the Project Gutenberg™ mission of promoting the free
distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.
Section 1. General Terms of Use and
Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund
from the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.
1.B. “Project Gutenberg” is a registered trademark. It may only be
used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
37.
1.C. The ProjectGutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
1.E. Unless you have removed all references to Project Gutenberg:
1.E.1. The following sentence, with active links to, or other
immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
38.
This eBook isfor the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.
1.E.2. If an individual Project Gutenberg™ electronic work is derived
from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.
1.E.3. If an individual Project Gutenberg™ electronic work is posted
with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.
1.E.4. Do not unlink or detach or remove the full Project
Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.
1.E.5. Do not copy, display, perform, distribute or redistribute this
electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
39.
with active linksor immediate access to the full terms of the Project
Gutenberg™ License.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.
1.E.7. Do not charge a fee for access to, viewing, displaying,
performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.
1.E.8. You may charge a reasonable fee for copies of or providing
access to or distributing Project Gutenberg™ electronic works
provided that:
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
40.
about donations tothe Project Gutenberg Literary Archive
Foundation.”
• You provide a full refund of any money paid by a user who
notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.
• You provide, in accordance with paragraph 1.F.3, a full refund of
any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™
electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.
1.F.
1.F.1. Project Gutenberg volunteers and employees expend
considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
41.
damaged disk orother medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.
1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for
the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.
1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you
discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
42.
INCLUDING BUT NOTLIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
1.F.5. Some states do not allow disclaimers of certain implied
warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.
1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,
the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.
Section 2. Information about the Mission
of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.
Volunteers and financial support to provide volunteers with the
assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
43.
remain freely availablefor generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.
Section 3. Information about the Project
Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.
The Foundation’s business office is located at 809 North 1500 West,
Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact
Section 4. Information about Donations to
the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many
44.
small donations ($1to $5,000) are particularly important to
maintaining tax exempt status with the IRS.
The Foundation is committed to complying with the laws regulating
charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.
While we cannot and do not solicit contributions from states where
we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.
International donations are gratefully accepted, but we cannot make
any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Section 5. General Information About
Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.
45.
Project Gutenberg™ eBooksare often created from several printed
editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
This website includes information about Project Gutenberg™,
including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.