Beginning C23 7Th Edition Ivor Horton 2 Full Chapter

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 37

Beginning C++23 7th Edition Ivor

Horton
Visit to download the full and correct content document:
https://ebookmass.com/product/beginning-c23-7th-edition-ivor-horton-2/
Ivor Horton and Peter Van Weert

Beginning C++23
From Beginner to Pro
7th ed.
Ivor Horton
Stratford-upon-Avon, Warwickshire, UK

Peter Van Weert


Kessel-Lo, Belgium

ISBN 978-1-4842-9342-3 e-ISBN 978-1-4842-9343-0


https://doi.org/10.1007/978-1-4842-9343-0

© Ivor Horton and Peter Van Weert 2014, 2018, 2020, 2023

This work is subject to copyright. All rights are solely and exclusively
licensed by the Publisher, whether the whole or part of the material is
concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in
any other physical way, and transmission or information storage and
retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed.

The use of general descriptive names, registered names, trademarks,


service marks, etc. in this publication does not imply, even in the
absence of a specific statement, that such names are exempt from the
relevant protective laws and regulations and therefore free for general
use.

The publisher, the authors, and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.
This Apress imprint is published by the registered company APress
Media, LLC, part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY
10004, U.S.A.
For my wonderful family. For all your love and support.
—Peter Van Weert
In memory of my wife, Eve
—Ivor Horton
Introduction
Welcome to Beginning C++23. This book is a revised and updated
version of Ivor Horton’s original one called Beginning ANSI C++. It
teaches the essentials of the C++ language and Standard Library
features. We’ll start with the basics and gradually guide you to the point
where you can write your own C++ applications. We by no means aim
to cover every single advanced language feature—properly explaining
those you’ll need daily will serve you much better—nor could we
possibly explore all nooks and corners of C++’s vast and ever-growing
Standard Library. Regardless, with the firm foundations and knowledge
you’ll get from this book, you should have no difficulty extending the
depth and scope of your C++ expertise going forward.
We assume no prior programming knowledge. If you are keen to
learn and have an aptitude for thinking logically, getting a grip on C++
will be easier than you might imagine. By developing C++ skills, you’ll
be learning a language that is already used by millions and that
provides the capability for application development in just about any
context.
C++ is powerful. Very powerful. Arguably, more powerful even than
most programming languages. So, yes, like with any powerful tool, you
can wield some considerable damage if you use it without proper
training. We often compare C++ to a Swiss Army knife: age-old, trusted,
incredibly versatile, yet potentially mind-boggling and full of pointy
things that could really hurt you. But once someone tells you what all
those pointy things are for and teaches you some elementary knife
safety rules, you’ll never have to look for another pocket knife again.
C++ does not need to be dangerous or difficult at all. C++ today is
much more accessible than many assume. The language has come a
long way since its conception nearly 40 years ago. We’ve learned how to
wield all its mighty blades and tools in the safest and most effective way
possible. And more importantly, the C++ language and its Standard
Library have evolved accordingly to facilitate this. The past decade has
seen the rise of what is now known as modern C++. Modern C++
emphasizes the use of newer, more expressive, and safer language
features combined with tried and tested best practices and coding
guidelines. Once you know and apply a handful of simple rules and
techniques, C++ loses much of its complexity. The key is that someone
properly and gradually explains not simply what you can do with C++
but rather what you should do with C++. And that’s where this book
comes in!
With every revision of the book, we go to great lengths to keep it in
line with the new, modern era of C++ programming we’re living in. We
pick and choose those improvements and extensions to the language
that are most relevant to those beginning C++. The C++ language in this
book corresponds to the latest International Organization for
Standardization (ISO) standard, commonly referred to as C++23. The
book introduces all relevant shiny blades and pointy things C++23 has
to offer—both old and new—using many hands-on coding samples and
exercises. We’ve made sure to always explain which tool is best to use
for which purpose, why that is the case, and how to avoid getting cut.
We’ve made sure that you will begin C++ from day one, using the safe,
productive, modern programming style that employers will expect from
you tomorrow.

Using the Book


To learn C++ with this book, you’ll need a compiler that conforms to the
C++23 standard and a text editor suitable for working with program
code. Several currently available compilers support, to some extent,
C++23 features, many of which are free.
GCC and Clang are free, open source compilers with solid and
rapidly increasing support for the latest versions of the language.
Installing these compilers and putting them together with a suitable
editor can be a little tricky if you are new to this kind of thing. An easy
way to install a compiler along with a suitable editor is to download a
free integrated development environment (IDEs) such as Code::Blocks
or Qt Creator. Such IDEs support complete program development for
several compilers, including GCC and Clang.
Another possibility is to use the commercial Microsoft Visual C++
IDE that runs under Microsoft Windows. The Community edition is free
for individual use and small professional teams, and its support for
C++23 is on par with GCC and Clang. With Visual Studio, you get a
comprehensive, easy-to-use professional editor and debugger, as well
as support for other languages, such as C# and JavaScript.
There are other compilers that support C++23 as well, which you
can find with a quick online search.

Note At the time of writing, no compiler fully supports C++23. If


the past is any guide, though, we are confident they will catch up
soon. Also, with only a few minimal workarounds, we were able to
compile and execute all sample C++23 code with our primary
compiler. In the online code repository of the book, you can find an
overview of tips and workarounds that should help you get started
with either one of the major compilers.

We’ve organized the material in this book to be read sequentially, so


you should start at the beginning and keep going until you reach the
end. However, no one ever learned programming by just reading a book.
You’ll only learn how to program in C++ by writing code, so make sure
you key in all the examples—don’t just copy them from the download
files—and compile and execute the code that you’ve keyed in. This
might seem tedious at times, but it’s surprising how much just typing in
C++ statements will help your understanding, especially when you’re
struggling with some of the ideas. If an example doesn’t work, resist the
temptation to return to the book to see why. Try to figure out from your
code what is wrong. This is good practice for what you’ll have to do
when you are developing C++ applications for real.
Making mistakes is a fundamental part of the learning process, and
the exercises should provide you with ample opportunity for that. It’s a
good idea to dream up a few exercises of your own. If you are unsure
how to do something, just have a go before looking it up. The more
mistakes you make, the greater the insight you’ll have into what can,
and does, go wrong. Make sure you attempt all the exercises, and
remember, don’t look at the solutions until you’re sure that you can’t
work them out yourself. Most of these exercises just involve a direct
application of what’s covered in a chapter—they’re just practice, in
other words—but some also require a bit of thought or inspiration.
We wish you every success with C++. Above all, enjoy it!
Ivor Horton
Peter Van Weert
Table of Contents
Chapter 1:​Basic Ideas
Modern C++
Standard Libraries
C++ Program Concepts
Source Files
Comments and Whitespace
The Standard Library and Modules
Functions
Statements
Text Output
return Statements
Namespaces
Identifiers and Keywords
Streams
Classes and Objects
Templates
Code Appearance and Programming Style
Creating an Executable
Procedural and Object-Oriented Programming
Representing Numbers
Binary Numbers
Hexadecimal Numbers
Negative Binary Numbers
Octal Values
Big-Endian and Little-Endian Systems
Floating-Point Numbers
Representing Characters
ASCII Codes
UCS and Unicode
Summary
Chapter 2:​Introducing Fundamental Types of Data
Variables, Data, and Data Types
Defining Integer Variables
Zero Initialization
Defining Variables with Fixed Values
Integer Literals
Decimal Integer Literals
Hexadecimal Literals
Octal Literals
Binary Literals
Calculations with Integers
Compound Arithmetic Expressions
Assignment Operations
The op=​Assignment Operators
Incrementing and Decrementing Integers
Postfix Increment and Decrement Operations
Floating-Point Variables
Standard Floating-Point Data Types
Extended Floating-Point Data Types
Floating-Point Literals
Finding the Limits
Finding Other Properties of Fundamental Types
The sizeof Operator
Floating-Point Calculations
Mathematical Constants
Mathematical Functions
Invalid Floating-Point Results
Pitfalls
Mixed Expressions and Type Conversion
Explicit Type Conversion
Old-Style Casts
The auto Keyword
Working with Character Variables
Working with Unicode Characters
Unicode Literals and Source File Encodings
Escape Sequences
Escaping Unicode Characters
Formatting
Modern Formatting
Formatting Stream Output
Summary
Chapter 3:​Working with Fundamental Data Types
Operator Precedence and Associativity
Bitwise Operators
The Bitwise Shift Operators
Logical Operations on Bit Patterns
The Lifetime of a Variable
Global Variables
Enumerated Data Types
Aliases for Data Types
Summary
Chapter 4:​Making Decisions
Comparing Data Values
Applying the Comparison Operators
Comparing Floating-Point Values
The Spaceship Operator
The if Statement
Nested if Statements
Character Classification and Conversion
The if-else Statement
Nested if-else Statements
Understanding Nested ifs
Logical Operators
Logical AND
Logical OR
Logical Negation
Combining Logical Operators
Logical Operators on Integer Operands
Logical Operators vs.​Bitwise Operators
The Conditional Operator
The switch Statement
Fallthrough
Switching on Enumeration Values
Statement Blocks and Variable Scope
Initialization Statements
Summary
Chapter 5:​Arrays and Loops
Arrays
Using an Array
Understanding Loops
The for Loop
Avoiding Magic Numbers
Defining the Array Size with the Braced Initializer
Determining the Size of an Array
Controlling a for Loop with Floating-Point Values
More Complex for Loop Control Expressions
The Comma Operator
The Range-Based for Loop
The while Loop
The do-while Loop
Nested Loops
Skipping Loop Iterations
Breaking Out of a Loop
Indefinite Loops
Controlling a for Loop with Unsigned Integers
Arrays of Characters
Multidimensional​Arrays
Initializing Multidimensional​Arrays
Multidimensional​Character Arrays
Allocating an Array at Runtime
Alternatives to Using an Array
Using array<T,N> Containers
Using std:​:v
​ ector<T> Containers
Formatting Ranges
Summary
Chapter 6:​Pointers and References
What Is a Pointer?​
The Address-Of Operator
The Indirection Operator
Why Use Pointers?​
Pointers to Type char
Arrays of Pointers
Constant Pointers and Pointers to Constants
Pointers and Arrays
Pointer Arithmetic
Using Pointer Notation with an Array Name
Dynamic Memory Allocation
The Stack and the Free Store
Using the new and delete Operators
Dynamic Allocation of Arrays
Member Selection Through a Pointer
Hazards of Dynamic Memory Allocation
Dangling Pointers and Multiple Deallocations
Allocation/​Deallocation Mismatch
Memory Leaks
Fragmentation of the Free Store
Golden Rule of Dynamic Memory Allocation
Raw Pointers and Smart Pointers
Using unique_​ptr<T> Pointers
Using shared_​ptr<T> Pointers
Understanding References
Defining References
Using a Reference Variable in a Range-Based for Loop
Summary
Chapter 7:​Working with Strings
A Better Class of String
Defining string Objects
Copying and Marking Substrings
Formatting and Reading String Objects
Operations with String Objects
Accessing Characters in a String
Accessing Substrings
Comparing Strings
Searching Strings
Modifying a String
std:​:s​ tring vs.​std:​:v
​ ector<char>
Converting Strings into Numbers
Strings of International Characters
Strings of wchar_​t Characters
Objects That Contain Unicode Strings
Raw String Literals
Summary
Chapter 8:​Defining Functions
Segmenting Your Programs
Functions in Classes
Characteristics of a Function
Defining Functions
The Function Body
Return Values
Function Declarations
Passing Arguments to a Function
Pass-by-Value
Pass-by-Reference
Default Argument Values
Multiple Default Argument Values
Arguments to main()
Returning Values from a Function
Returning a Pointer
Returning a Reference
Returning vs.​Output Parameters
Return Type Deduction
Static Local Variables
Function Overloading
Overloading and Pointer Parameters
Overloading and Reference Parameters
Overloading and const Parameters
Overloading and Default Argument Values
Recursion
Basic Examples of Recursion
Recursive Algorithms
Constant Expressions
constexpr Variables
constexpr Functions
Limitations to Constant Expressions
Summary
Chapter 9:​Vocabulary Types
Working with Optional Values
std:​:o
​ ptional
std:​:e
​ xpected
String Views:​The New Reference-to-const-string
Using String View Function Parameters
A Proper Motivation
Spans:​The New Reference-to-vector or -array
Writing Through a Span
Spans of const Elements
Fixed-Size Spans
Summary
Chapter 10:​Function Templates
Function Templates
Creating Instances of a Function Template
Template Type Parameters
Explicit Template Arguments
Function Template Specialization
Function Templates and Overloading
Function Templates with Multiple Parameters
Return Type Deduction in Templates
decltype(auto)
constexpr If
Default Values for Template Parameters
Non-Type Template Parameters
Templates for Functions with Fixed-Size Array Arguments
Abbreviated Function Templates
Limitations to Abbreviated Function Templates
Summary
Chapter 11:​Modules and Namespaces
Modules
Your First Module
Export Blocks
Separating Interface from Implementation
Reachability vs.​Visibility
Exporting Import Declarations
Managing Larger Modules
Namespaces
The Global Namespace
Defining a Namespace
Nested Namespaces
Namespaces and Modules
Functions and Namespaces
Using Directives and Declarations
Namespace Aliases
Summary
Chapter 12:​Defining Your Own Data Types
Classes and Object-Oriented Programming
Encapsulation
Inheritance
Polymorphism
Terminology
Defining a Class
Creating Objects of a Class
Constructors
Default Constructors
Defining a Class Constructor
Using the default Keyword
Defining Functions Outside the Class
Default Arguments for Constructor Parameters
Using a Member Initializer List
Using the explicit Keyword
Delegating Constructors
The Copy Constructor
Defining Classes in Modules
Accessing Private Class Members
The this Pointer
Returning this from a Function
const Objects and const Member Functions
const Member Functions
const Correctness
Overloading on const
Casting Away const
Using the mutable Keyword
Friends
The Friend Functions of a Class
Friend Classes
Arrays of Class Objects
The Size of a Class Object
Static Members of a Class
Static Member Variables
Accessing Static Member Variables
Static Constants
Static Member Variables of the Class Type Itself
Static Member Functions
Destructors
constexpr Member Functions
consteval Constructors
Using Pointers as Class Members
The Truckload Example
Nested Classes
Nested Classes with Public Access
A Better Mechanism for Traversing a Truckload:​Iterators
Summary
Chapter 13:​Operator Overloading
Implementing Operators for a Class
Operator Overloading
Implementing an Overloaded Operator
Nonmember Operator Functions
Implementing Full Support for an Operator
Operators That Can Be Overloaded
Restrictions and Key Guideline
Operator Function Idioms
Supporting All Comparison Operators
Defaulting Comparison Operators
Overloading the << Operator for Output Streams
Overloading the Arithmetic Operators
Implementing One Operator in Terms of Another
Member vs.​Nonmember Functions
Operator Functions and Implicit Conversions
Overloading Unary Operators
Overloading the Increment and Decrement Operators
Overloading the Subscript Operator
Modifying the Result of an Overloaded Subscript Operator
Function Objects
Overloading Type Conversions
Potential Ambiguities with Conversions
Overloading the Assignment Operator
Implementing the Copy Assignment Operator
Copy Assignment vs.​Copy Construction
Deleting the Copy Assignment Operator
Assigning Different Types
Summary
Chapter 14:​Inheritance
Classes and Object-Oriented Programming
Hierarchies
Inheritance in Classes
Inheritance vs.​Aggregation and Composition
Deriving Classes
Protected Members of a Class
The Access Level of Inherited Class Members
Access Specifiers and Class Hierarchies
Choosing Access Specifiers in Class Hierarchies
Changing the Access Specification of Inherited Members
Constructors in a Derived Class
The Copy Constructor in a Derived Class
The Default Constructor in a Derived Class
Inheriting Constructors
Destructors Under Inheritance
Duplicate Member Variable Names
Duplicate Member Function Names
Multiple Inheritance
Multiple Base Classes
Inherited Member Ambiguity
Repeated Inheritance
Virtual Base Classes
Converting Between Related Class Types
Summary
Chapter 15:​Polymorphism
Understanding Polymorphism
Using a Base Class Pointer
Calling Inherited Functions
Virtual Functions
Requirements for Virtual Function Operation
Using the override Specifier
Using final
Virtual Functions and Class Hierarchies
Access Specifiers and Virtual Functions
Default Argument Values in Virtual Functions
Using References to Call Virtual Functions
Polymorphic Collections
Destroying Objects Through a Pointer
Virtual Destructors
Converting Between Pointers to Class Objects
Dynamic Casts
Casting Pointers Dynamically
Dynamic Casts and const
Converting References
Calling the Base Class Version of a Virtual Function
Calling Virtual Functions from Constructors or Destructors
How Polymorphic Function Calls Work
Determining the Dynamic Type
Pure Virtual Functions
Abstract Classes
An Abstract Box Class
Abstract Classes as Interfaces
Summary
Chapter 16:​Runtime Errors and Exceptions
Handling Errors
Understanding Exceptions
Throwing an Exception
The Exception-Handling Process
Code That Causes an Exception to Be Thrown
Nested try Blocks
Class Objects as Exceptions
Matching a Catch Handler to an Exception
Catching Derived Class Exceptions with a Base Class Handler
Rethrowing Exceptions
Unhandled Exceptions
Catching All Exceptions
Functions That Don’t Throw Exceptions
The noexcept Specifier
Exceptions and Destructors
Exceptions and Resource Leaks
Resource Acquisition Is Initialization
Standard RAII Classes for Dynamic Memory
Standard Library Exceptions
The Exception Class Definitions
Using Standard Exceptions
Stack Traces
Summary
Chapter 17:​Class Templates
Understanding Class Templates
Defining Class Templates
Template Type Parameters
A Simple Class Template
Defining Member Functions of a Class Template
Constructor Templates
The Destructor Template
Subscript Operator Templates
The Assignment Operator Template
Class Template Instantiation
Explicit Template Instantiation
Testing the Array Class Template
Non-Type Class Template Parameters
Templates for Member Functions with Non-Type
Parameters
Arguments for Non-Type Parameters
Non-Type Template Arguments vs.​Constructor Arguments
Default Values for Template Parameters
Class Template Argument Deduction
Class Template Specialization
Defining a Class Template Specialization
Partial Template Specialization
Class Templates with Nested Classes
Function Templates for Stack Members
Dependent Names Nuisances
Dependent Type Names
Dependent Base Classes
Summary
Chapter 18:​Move Semantics
Lvalues and Rvalues
Rvalue References
Moving Objects
Defining Move Members
Explicitly Moved Objects
Move-Only Types
Extended Use of Moved Objects
A Barrel of Contradictions
std:​:m
​ ove() Does Not Move
An Rvalue Reference Is an Lvalue
Defining Functions Revisited
Pass-by-Rvalue-Reference
The Return of Pass-by-Value
Return-by-Value
Defining Move Members Revisited
Always Add noexcept
The “Move-and-Swap” Idiom
Special Member Functions
Default Move Members
The Rule of Five
The Rule of Zero
Summary
Chapter 19:​First-Class Functions
Pointers to Functions
Defining Pointers to Functions
Callback Functions for Higher-Order Functions
Type Aliases for Function Pointers
Function Objects
Basic Function Objects
Standard Function Objects
Parameterized Function Objects
Lambda Expressions
Defining a Lambda Expression
Naming a Lambda Closure
Passing a Lambda Expression to a Function Template
Generic Lambdas
The Capture Clause
The std:​:f​ unction<> Template
Summary
Chapter 20:​Containers and Algorithms
Containers
Sequence Containers
Stacks and Queues
Associative Containers
Iterators
The Iterator Design Pattern
Iterators for Standard Library Containers
Iterators for Arrays
Algorithms
A First Example
Finding Elements
Handling Multiple Output Values
The Remove-Erase Idiom
Sorting
Parallel Algorithms
Ranges and Views
Range-Based Algorithms
Views
Summary
Chapter 21:​Constrained Templates and Concepts
Unconstrained Templates
Constrained Templates
Concepts
Concept Definitions and Expressions
Requires Expressions
Asserting That a Type Models a Concept
Standard Concepts
Requires Clauses
Shorthand Notation
Constrained Function Templates
Constrained Class Templates
Constrained Class Members
Constraint-Based Overloading
Another random document with
no related content on Scribd:
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
about donations to the 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
damaged disk or other 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,
INCLUDING BUT NOT LIMITED 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
remain freely available for 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 small
donations ($1 to $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.

Project Gutenberg™ eBooks are 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.

You might also like