100% found this document useful (15 votes)
141 views60 pages

C Primer Plus 4th Ed Edition Stephen Prata 2024 Scribd Download

Stephen

Uploaded by

bittorgotzl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (15 votes)
141 views60 pages

C Primer Plus 4th Ed Edition Stephen Prata 2024 Scribd Download

Stephen

Uploaded by

bittorgotzl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 60

Download the full version of the ebook at ebookname.

com

C Primer Plus 4th ed Edition Stephen Prata

https://ebookname.com/product/c-primer-plus-4th-ed-edition-
stephen-prata/

OR CLICK BUTTON

DOWNLOAD EBOOK

Download more ebook instantly today at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Programming in C 4th Edition Stephen G. Kochan

https://ebookname.com/product/programming-in-c-4th-edition-stephen-g-
kochan/

ebookname.com

Test Your C Skills 4th Ed 4th Edition Yashavant Kanetkar

https://ebookname.com/product/test-your-c-skills-4th-ed-4th-edition-
yashavant-kanetkar/

ebookname.com

Control valve primer a user s guide 4th ed Edition Hans D.


Baumann

https://ebookname.com/product/control-valve-primer-a-user-s-guide-4th-
ed-edition-hans-d-baumann/

ebookname.com

A Social History of Knowledge II From the Encyclopaedia to


Wikipedia 1st Edition Peter Burke

https://ebookname.com/product/a-social-history-of-knowledge-ii-from-
the-encyclopaedia-to-wikipedia-1st-edition-peter-burke/

ebookname.com
Reinforced Concrete Mechanics and Design 7th edition /
Global edition Edition James K. Wight

https://ebookname.com/product/reinforced-concrete-mechanics-and-
design-7th-edition-global-edition-edition-james-k-wight/

ebookname.com

Distance and Blended Learning in Asia The Open and


Flexible Learning Series 1st Edition Colin Latchem

https://ebookname.com/product/distance-and-blended-learning-in-asia-
the-open-and-flexible-learning-series-1st-edition-colin-latchem/

ebookname.com

Non Ionizing Radiation Static and Extremely Low Frequency


ELF Electric and Magnetic Fields IARC Monographs on the
Evaluation of the Carcinogenic Risks to Humans 1st Edition
The International Agency For Research On Cancer
https://ebookname.com/product/non-ionizing-radiation-static-and-
extremely-low-frequency-elf-electric-and-magnetic-fields-iarc-
monographs-on-the-evaluation-of-the-carcinogenic-risks-to-humans-1st-
edition-the-international-agency-fo/
ebookname.com

Materials and Processes in Manufacturing 11e 11th Edition


John Wiley & Sons

https://ebookname.com/product/materials-and-processes-in-
manufacturing-11e-11th-edition-john-wiley-sons/

ebookname.com

Biological Science 5th Edition Scott Freeman

https://ebookname.com/product/biological-science-5th-edition-scott-
freeman/

ebookname.com
Manuscript Miscellanies in Early Modern England Joshua
Eckhardt

https://ebookname.com/product/manuscript-miscellanies-in-early-modern-
england-joshua-eckhardt/

ebookname.com
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks.

C++ Primer Plus, Fourth Edition


By Stephen Prata

Publisher: Sams Publishing


Pub Date: November 14, 2001
ISBN: 0672322234
Table of Pages: 1128

Contents
• Index C++ Primer Plus, Fourth Edition presents the ANSI C++ standard beginning with a
discussion of the essential elements of C++ programming: loops, expressions,
functions, and classes. It walks readers through the basics of object-oriented
programming: classes, inheritance, templates, and exceptions, as well as the latest
object-oriented programming techniques. C++ Primer Plus contains hundreds of
sample programs. The friendly tone, concise programs, and end-of-chapter review
exercises allow beginners to write their own programs immediately.

Copyright 777
PREFACE
Preface to the Fourth Edition
Note to Instructors
How This Book Is Organized

ABOUT THE AUTHOR


ACKNOWLEDGMENTS
TELL US WHAT YOU THINK!
Chapter 1. GETTING STARTED
Learning C++
A Little History
Portability and Standards
The Mechanics of Creating a Program
Conventions Used in This Book
Our System

Chapter 2. SETTING OUT TO C++


C++ Initiation
More About C++ Statements
More C++ Statements
Functions
Summary
Review Questions
Programming Exercises

Chapter 3. DEALING WITH DATA


Simple Variables
The const Qualifier
Floating-Point Numbers
C++ Arithmetic Operators
Summary
Review Questions
Programming Exercises
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks.

Chapter 4. COMPOUND TYPES


Introducing Arrays
Strings
Introducing Structures
Unions
Enumerations
Pointers and the Free Store
Pointers, Arrays, and Pointer Arithmetic
Summary
Review Questions
Programming Exercises

Chapter 5. LOOPS AND RELATIONAL EXPRESSIONS


Introducing the for Loop
Relational Expressions
The while Loop
The do while Loop
Loops and Text Input
Nested Loops and Two-Dimensional Arrays
Summary
Review Questions
Programming Exercises

Chapter 6. BRANCHING STATEMENTS AND LOGICAL OPERATORS


The if Statement
Logical Expressions
The cctype Library of Character Functions
The ?: Operator
The switch Statement
The break and continue Statements
Number-Reading Loops
Summary
Review Questions
Programming Exercises

Chapter 7. FUNCTIONS?C++'S PROGRAMMING MODULES


Function Review
Function Arguments and Passing by Value
Functions and Arrays
Functions and Two-Dimensional Arrays
Functions and C-Style Strings
Functions and Structures
Recursion
Pointers to Functions
Summary
Review Questions
Programming Exercises

Chapter 8. ADVENTURES IN FUNCTIONS


Inline Functions
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks.

Reference Variables
Default Arguments
Function Polymorphism (Function Overloading)
Function Templates
Summary
Review Questions
Programming Exercises

Chapter 9. MEMORY MODELS AND NAMESPACES


Separate Compilation
Storage Duration, Scope, and Linkage
Namespaces
Summary
Review Questions
Programming Exercises

Chapter 10. OBJECTS AND CLASSES


Procedural and Object-Oriented Programming
Abstraction and Classes
Class Constructors and Destructors
Knowing Your Objects: The this Pointer
An Array of Objects
Class Scope
An Abstract Data Type
Summary
Review Questions
Programming Exercises

Chapter 11. WORKING WITH CLASSES


Operator Overloading
Time on Our Hands
Introducing Friends
Overloaded Operators: Member Versus Nonmember Functions
More Overloading: A Vector Class
Automatic Conversions and Type Casts for Classes
Summary
Review Questions
Programming Exercises

Chapter 12. CLASSES AND DYNAMIC MEMORY ALLOCATION


Dynamic Memory and Classes
A Queue Simulation
Summary
Review Questions
Programming Exercises

Chapter 13. CLASS INHERITANCE


Beginning with a Simple Base Class
Special Relationships
Inheritance?An Is-a Relationship
Polymorphic Public Inheritance
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks.

Access Control-protected
Abstract Base Classes
Inheritance and Dynamic Memory Allocation
Class Design Review
Summary
Review Questions
Programming Exercises

Chapter 14. REUSING CODE IN C++


Classes with Object Members
Private Inheritance
Multiple Inheritance
Class Templates
Summary
Review Questions
Programming Exercises

Chapter 15. FRIENDS, EXCEPTIONS, AND MORE


Friends
Nested Classes
Exceptions
RTTI
Type Cast Operators
Summary
Review Questions
Programming Exercises

Chapter 16. THE string CLASS AND THE STANDARD TEMPLATE LIBRARY
The string Class
The auto_ptr Class
The Standard Template Library
Generic Programming
Function Objects (aka Functors)
Algorithms
Other Libraries
Summary
Review Questions
Programming Exercises

Chapter 17. INPUT, OUTPUT, AND FILES


An Overview of C++ Input and Output
Output with cout
Input with cin
File Input and Output
Incore Formatting
What Now?
Summary
Review Questions
Programming Exercises

Appendix A. NUMBER BASES


This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks.

Octal Integers
Hexadecimal Numbers
Binary Numbers
Binary and Hex

Appendix B. C++ KEYWORDS


Appendix C. THE ASCII CHARACTER SET
Appendix D. OPERATOR PRECEDENCE
Appendix E. OTHER OPERATORS
Bitwise Operators
Member Dereferencing Operators

Appendix F. THE string TEMPLATE CLASS


Thirteen Types and a Constant
Data Information, Constructors, and So On
String Access
Basic Assignment
String Searching
Comparison Methods and Functions
String Modifiers
Output and Input

Appendix G. THE STL METHODS AND FUNCTIONS


Members Common to All Containers
Additional Members for Vectors, Lists, and Deques
Additional Members for Sets and Maps
STL Functions

Appendix H. SELECTED READINGS


Appendix I. CONVERTING TO ANSI/ISO STANDARD C++
Preprocessor Directives
Use Function Prototypes
Type Casts
Become Familiar with C++ Features
Use the New Header Organization
Use Namespaces
Use the autoptr Template
Use the string Class
Use the STL

Appendix J. ANSWERS TO REVIEW QUESTIONS


Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks

Chapter 12
Chapter 13
Chapter 14
Chapter 15
Chapter 16
Chapter 17

Index

Copyright

Copyright ©2002 by Sams Publishing

All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted
by any means, electronic, mechanical, photocopying, recording, or otherwise, without written
permission from the publisher. No patent liability is assumed with respect to the use of the information
contained herein. Although every precaution has been taken in the preparation of this book, the
publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for
damages resulting from the use of the information contained herein.

Library of Congress Catalog Card Number: 2001089224

Printed in the United States of America

First Printing: November 2001

03 02 01 00 4 3 2 1

Trademarks

All terms mentioned in this book that are known to be trademarks or service marks have been
appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Use of a
term in this book should not be regarded as affecting the validity of any trademark or service mark.

Warning and Disclaimer

Every effort has been made to make this book as complete and as accurate as possible, but no
warranty or fitness is implied. The information provided is on an "as is" basis. The author and the
publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or
damages arising from the information contained in this book or from the use of the programs
accompanying it.

Credits
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks

ASSOCIATE PUBLISHER

Linda Engelman

ACQUISITIONS EDITOR

Linda Scharp

DEVELOPMENT EDITOR

Karen Wachs

MANAGING EDITOR

Charlotte Clapp

INDEXER

Kelly Castell

PROOFREADERS

Bob LaRoche

Jessica McCarty

TECHNICAL EDITORS

Philippe Bruno

Bill Craun

Michael Maddox

Chris Maunder

TEAM COORDINATOR

Lynne Williams

INTERIOR DESIGNER

Gary Adair

COVER DESIGNER

Gary Adair

PAGE LAYOUT
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks .

Ayanna Lacey

Stacey Richwine-DeRome

DEDICATION

To my colleagues and students at the College of Marin, with whom it is a pleasure to work.

—Stephen Prata

PREFACE

Preface to the Fourth Edition


Note to Instructors
How This Book Is Organized

Preface to the Fourth Edition

Learning C++ is an adventure of discovery, particularly because the language accommodates several
programming paradigms, including object-oriented programming, generic programming, and the
traditional procedural programming. C++ has been a moving target as the language added new
features, but now, with the ISO/ANSI C++ Standard of 1998 in place, the language has stabilized.
Contemporary compilers support most or all of the features mandated by the standard, and
programmers have had time to get used to applying these features. The Fourth Edition of C++ Primer
Plus reflects the ISO/ANSI standard and describes this matured version of C++.

C++ Primer Plus integrates discussing the basic C language with presenting C++ features, making this
book self-contained. It presents C++ fundamentals and illustrates them with short, to-the-point
programs that are easy to copy and experiment with. You'll learn about input and output, how to make
programs perform repetitive tasks and make choices, the many ways to handle data, and how to use
functions. You'll learn about the many features C++ has added to C, including the following:

Classes and objects

Inheritance

Polymorphism, virtual functions, and RTTI (runtime type identification)

Function overloading

Reference variables

Generic, or type-independent programming, as provided by templates and the Standard


Template Library (STL)
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks .

The exception mechanism for handling error conditions

Namespaces for managing names of functions, classes, and variables

C++ Primer Plus brings several virtues to the task of presenting all this material. It builds upon the
primer tradition begun by C Primer Plus nearly two decades ago and embraces its successful
philosophy:

A primer should be an easy-to-use, friendly guide.

A primer doesn't assume that you already are familiar with all relevant programming concepts.

A primer emphasizes hands-on learning with brief, easily typed examples that develop your
understanding a concept or two at a time.

A primer clarifies concepts with illustrations.

A primer provides questions and exercises to let you test your understanding, making the book
suitable for self-learning or for the classroom.

The book helps you understand this rich language and how to use it.

It provides conceptual guidance about when to use particular features, such as using public
inheritance to model what are known as is-a relationships.

It illustrates common C++ programming idioms and techniques.

It provides a variety of sidebars, including tips, cautions, and real-world notes.

We (the author and editors) do our best to keep the presentation to-the-point, simple, and fun. Our goal
is that by the end of the book you'll be able to write solid, effective programs and enjoy yourself doing
so.

Like the previous editions, this book practices generic C++ so that it is not tied to any particular kind of
computer, operating system, or compiler. All the programs were tested with CodeWarrior Pro 6
(Macintosh and Windows) and Microsoft Visual C++ 6.0, and most were tested with Borland C++
Command-Line Compiler 5.5, Gnu g++ 2.9.5 running under DOS, and Comeau C/C++ 4.42.5 running
under Linux. Only a few programs were affected by compiler non-conformance issues.

C++ offers a lot to the programmer; learn and enjoy!

Note to Instructors

One of the goals of the fourth edition is to provide a book that can be used as either a teach-yourself
book or a textbook. Here are some of the features that support using C++ Primer Plus, Fourth Edition
as a textbook:
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks .

This book describes generic C++, so it isn't dependent upon a particular implementation.

The contents track the ISO/ANSI C++ standards committee's work and include discussions of
templates, the Standard Template Library, the string class, exceptions, RTTI, and namespaces.

It doesn't assume prior knowledge of C, so it can be used without a C prerequisite. (Some


programming background is desirable, however.)

Topics are arranged so that the early chapters can be covered rapidly as review chapters for
courses that do have a C prerequisite.

Chapters have review questions and programming exercises.

The book introduces several topics appropriate for computer science courses, including abstract
data types, stacks, queues, simple lists, simulations, generic programming, and using recursion
to implement a divide-and-conquer strategy.

Most chapters are short enough to cover in a week or less.

The book discusses when to use certain features as well as how to use them. For example, it
links public inheritance to is-a relationships and composition and private inheritance to has-a
relationships, and it discusses when to use virtual functions and when not to.

How This Book Is Organized

This book is divided into 17 chapters and 10 appendixes summarized here.

Chapter 1: Getting Started

This chapter relates how Bjarne Stroustrup created the C++ programming language by adding
object-oriented programming support to the C language. You'll learn the distinctions between
procedural languages, such as C, and object-oriented languages, such as C++. You'll read about the
joint ANSI/ISO work to develop a C++ standard. The chapter discusses the mechanics of creating a
C++ program, outlining the approach for several current C++ compilers. Finally, it describes the
conventions used in this book.

Chapter 2: Setting Out to C++

Chapter 2 guides you through the process of creating simple C++ programs. You'll learn about the role
of the main() function and about some of the kinds of statements that C++ programs use. You'll use
the predefined cout and cin objects for program output and input, and you'll learn about creating and
using variables. Finally, you'll be introduced to functions, C++'s programming modules.

Chapter 3: Dealing with Data

C++ provides built-in types for storing two kinds of data: integers (numbers with no fractional parts) and
floating-point numbers (numbers with fractional parts). To meet the diverse requirements of
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks .

programmers, C++ offers several types in each category. This chapter discusses these types, including
creating variables and writing constants of various types. You'll also learn how C++ handles implicit
and explicit conversions from one type to another.

Chapter 4: Compound Types

C++ lets you construct more elaborate types from the basic built-in types. The most advanced form is
the class, discussed in Chapters 10, 11, 12, 13 and 14. This chapter discusses other forms, including
arrays, which hold several values of a single type; structures, which hold several values of unlike
types; and pointers, which identify locations in memory. You'll also learn how to create and store text
strings and to handle text input and output. Finally, you'll learn some of the ways C++ handles memory
allocation, including the new and delete operators for managing memory explicitly.

Chapter 5: Loops and Relational Expressions

Programs often must perform repetitive actions, and C++ provides three looping structures for that
purpose: the for loop, the while loop, and the do while loop. Such loops must know when they should
terminate, and the C++ relational operators enable you to create tests to guide such loops. You'll also
learn how to create loops that read and process input character-by-character. Finally, you'll learn how
to create two-dimensional arrays and how to use nested loops to process them.

Chapter 6: Branching Statements and Logical Operators

Programs can behave intelligently if they can tailor their behavior to circumstances. In this chapter
you'll learn how to control program flow by using the if , if else , and switch statements and the
conditional operator. You'll learn how to use logical operators to help express decision-making tests.
Also, you'll meet the cctype library of functions for evaluating character relations, such as testing
whether a character is a digit or a nonprinting character.

Chapter 7: Functions?C++'s Programming Modules

Functions are the basic building blocks of C++ programming. This chapter concentrates on features
that C++ functions share with C functions. In particular, you'll review the general format of a function
definition and examine how function prototypes increase the reliability of programs. Also, you'll
investigate how to write functions to process arrays, character strings, and structures. Next you'll learn
about recursion, which is when a function calls itself, and see how it can be used to implement a
divide-and-conquer strategy. Finally, you'll meet pointers to functions, which enable you to use a
function argument to tell one function to use a second function.

Chapter 8: Adventures in Functions

This chapter explores the new features C++ adds to functions. You'll learn about inline functions, which
can speed program execution at the cost of additional program size. You'll work with reference
variables, which provide an alternative way to pass information to functions. Default arguments let a
function automatically supply values for function arguments that you omit from a function call. Function
overloading lets you create functions having the same name but taking different argument lists. All
these features have frequent use in class design. Also, you'll learn about function templates, which
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks .

allow you to specify the design of a family of related functions.

Chapter 9: Memory Models and Namespaces

This chapter discusses putting together multifile programs. It examines your choices in allocating
memory, looking at different methods of managing memory and at scope, linkage, and namespaces,
which determine what parts of a program know about a variable.

Chapter 10: Objects and Classes

A class is a user-defined type, and an object is an instance of a class, such as a variable. This chapter
introduces you to object-oriented programming and to class design. A class declaration describes the
information stored in a class object and also the operations (class methods) allowed for class objects.
Some parts of an object are visible to the outside world (the public portion), and some are hidden (the
private portion). Special class methods (constructors and destructors) come into play when objects are
created and destroyed. You will learn about all this and other class details in this chapter, and you'll
see how classes can be used to implement abstract data types (ADTs), such as a stack.

Chapter 11: Working with Classes

In this chapter you'll further your understanding of classes. First you'll learn about operator
overloading, which lets you define how operators such as + will work with class objects. You'll learn
about friend functions, which can access class data that's inaccessible to the world at large. You'll see
how certain constructors and overloaded operator member functions can be used to manage
conversion to and from class types.

Chapter 12: Classes and Dynamic Memory Allocation

Often it's useful to have a class member point to dynamically allocated memory. If you use new in a
class constructor to allocate dynamic memory, you incur the responsibilities of providing an appropriate
destructor, of defining an explicit copy constructor, and of defining an explicit assignment operator.
This chapter shows you how and discusses the behavior of the member functions generated implicitly
if you fail to provide explicit definitions. You'll also expand your experience with classes by using
pointers to objects and studying a queue simulation problem.

Chapter 13: Class Inheritance

One of the most powerful features of object-oriented programming is inheritance, by which a derived
class inherits the features of a base class, enabling you to reuse the base class code. This chapter
discusses public inheritance, which models is-a relationships, meaning that a derived object is a
special case of a base object. For example, a physicist is a special case of a scientist. Some
inheritance relationships are polymorphic, meaning you can write code using a mixture of related
classes for which the same method name may invoke behavior that depends upon the object type.
Implementing this kind of behavior necessitates using a new kind of member function called a virtual
function. Sometimes abstract base classes are the best approach to inheritance relationships. This
chapter discusses these matters, pointing out when public inheritance is appropriate and when it is not.
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks

Chapter 14: Reusing Code in C++

Public inheritance is just one way to reuse code. This chapter looks at several other ways.
Containment is when one class contains members that are objects of another class. It can be used to
model has-a relationships, in which one class has components of another class. For example, an
automobile has a motor. You also can use private and protected inheritance to model such
relationships. This chapter shows you how and points out the differences among the different
approaches. Also, you'll learn about class templates, which let you define a class in terms of some
unspecified generic type, then use the template to create specific classes in terms of specific types. For
example, a stack template enables you to create a stack of integers or a stack of strings. Finally, you'll
learn about multiple public inheritance, whereby a class can derive from more than one class.

Chapter 15: Friends, Exceptions, and More

This chapter extends the discussion of friends to include friend classes and friend member functions.
Then it presents several new developments in C++, beginning with exceptions, which provide a
mechanism for dealing with unusual program occurrences, such an inappropriate function argument
values or running out of memory. Then you'll learn about RTTI (runtime type information), a
mechanism for identifying object types. Finally, you'll learn about the safer alternatives to unrestricted
typecasting.

Chapter 16: The string Class and the Standard Template Library

This chapter discusses some useful class libraries recently added to the language. The string class is
a convenient and powerful alternative to traditional C-style strings. The auto_ptr class helps manage
dynamically allocated memory. The Standard Template Library (STL) provides several generic
containers, including template representations of arrays, queues, lists, sets, and maps. It also provides
an efficient library of generic algorithms that can be used with STL containers and also with ordinary
arrays.

Chapter 17: Input, Output, and Files

This chapter reviews C++ I/O and discusses how to format output. You'll learn how to use class
methods to determine the state of an input or output stream and to see, for example, if there has been
a type mismatch on input or if end-of-file has been detected. C++ uses inheritance to derive classes for
managing file input and output. You'll learn how to open files for input and output, how to append data
to a file, how to use binary files, and how to get random access to a file. Finally, you'll learn how to
apply standard I/O methods to read from and write to strings.

Appendix A: Number Bases

This appendix discusses octal, hexadecimal, and binary numbers.

Appendix B: C++ Keywords

This appendix lists C++ keywords.

Appendix C: The ASCII Character Set


This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks .

This appendix lists the ASCII character set along with decimal, octal, hexadecimal, and binary
representations.

Appendix D: Operator Precedence

This appendix lists the C++ operators in order of decreasing precedence.

Appendix E: Other Operators

This appendix summarizes those C++ operators, such as the bitwise operators, not covered in the
main body of the text.

Appendix F: The string Template Class

This appendix summarizes string class methods and functions.

Appendix G: The STL Methods and Functions

This appendix summarizes the STL container methods and the general STL algorithm functions.

Appendix H: Selected Readings

This appendix lists some books that can further your understanding of C++.

Appendix I: Converting to ANSI/ISO Standard C++

This appendix provides guidelines for moving from C and older C++ implementations to Standard C++.

Appendix J: Answers to Review Questions

This appendix contains the answers to the review questions posed at the end of each chapter.

ABOUT THE AUTHOR

Stephen Prata teaches astronomy, physics, and computer science at the College of Marin in Kentfield,
California. He received his B.S. from the California Institute of Technology and his Ph.D. from the
University of California, Berkeley. Stephen has authored or coauthored over a dozen books for The
Waite Group. He wrote The Waite Group's New C Primer Plus, which received the Computer Press
Association's 1990 Best How-to Computer Book Award and The Waite Group's C++ Primer Plus,
nominated for the Computer Press Association's Best How-to Computer Book Award in 1991.

ACKNOWLEDGMENTS

ACKNOWLEDGMENTS TO THE FOURTH EDITION

Several editors from Pearson and from Sams helped originate and maintain this project, so thanks to
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks .

Linda Sharp, Karen Wachs, and Laurie McGuire. Thanks, too, to Michael Maddox, Bill Craun, Chris
Maunder, and Phillipe Bruno for providing technical review and editing. And thanks again to Michael
Maddox and Bill Craun for supplying the material for the Real World Notes. Also, thank you Ron
Leichty of Metroworks and Greg Comeau of Comeau Computing for your help with the new C99
features and your noteworthy commitment to customer service.

ACKNOWLEDGMENTS TO THE THIRD EDITION

I'd like to thank the editors from Macmillan Press and Waite Group Press for the roles they played in
putting this book together: Tracy Dunkelberger, Susan Walton, and Andrea Rosenberg. Thanks, too, to
Russ Jacobs for his content and technical editing. From Metrowerks, I'd like to thank Dave Mark, Alex
Harper, and especially Ron Liechty, for their help and cooperation.

ACKNOWLEDGMENTS TO THE SECOND EDITION

I'd like to thank Mitchell Waite and Scott Calamar for supporting a second edition and Joel Fugazzotto
and Joanne Miller for guiding the project to completion. Thanks to Michael Marcotty of Metrowerks for
dealing with my questions about their beta version CodeWarrior compiler. I'd also like to thank the
following instructors for taking the time to give us feedback on the first edition: Jeff Buckwalter, Earl
Brynner, Mike Holland, Andy Yao, Larry Sanders, Shahin Momtazi, and Don Stephens. Finally, I wish
to thank Heidi Brumbaugh for her helpful content editing of new and revised material.

ACKNOWLEDGMENTS TO THE FIRST EDITION

Many people have contributed to this book. In particular, I wish to thank Mitch Waite for his work in
developing, shaping, and reshaping this book, and for reviewing the manuscript. I appreciate Harry
Henderson's work in reviewing the last few chapters and in testing programs with the Zortech C++
compiler. Thanks to David Gerrold for reviewing the entire manuscript and for championing the needs
of less-experienced readers. Also thanks to Hank Shiffman for testing programs using Sun C++ and to
Kent Williams for testing programs with AT&T cfront and with G++. Thanks to Nan Borreson of Borland
International for her responsive and cheerful assistance with Turbo C++ and Borland C++. Thank you,
Ruth Myers and Christine Bush, for handling the relentless paper flow involved with this kind of project.
Finally, thanks to Scott Calamar for keeping everything on track.

TELL US WHAT YOU THINK!

As the reader of this book, you are our most important critic and commentator. We value your opinion
and want to know what we're doing right, what we could do better, what areas you'd like to see us
publish in, and any other words of wisdom you're willing to pass our way.

As an Associate Publisher for Sams, I welcome your comments. You can e-mail or write me directly to
let me know what you did or didn't like about this book—as well as what we can do to make our books
stronger.

Please note that I cannot help you with technical problems related to the topic of this book, and that
due to the high volume of mail I receive, I might not be able to reply to every message.
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks .

When you write, please be sure to include this book's title and author as well as your name and phone
or fax number. I will carefully review your comments and share them with the author and editors who
worked on the book.

E-mail: [email protected]
Mail: Linda Engelman
Sams
201 West 103rd Street
Indianapolis, IN 46290 USA
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks

CONTENTS

Chapter 1. GETTING STARTED

You will learn about the following in this chapter:

Learning C++
A Little History
Portability and Standards
The Mechanics of Creating a Program
Conventions Used in This Book
Our System

Welcome to C++! This exciting language, blending the C language with support for
object-oriented programming, became one of the most important programming
languages of the 1990s and continues strongly into the 2000s. Its C ancestry brings to
C++ the tradition of an efficient, compact, fast, and portable language. Its
object-oriented heritage brings C++ a fresh programming methodology designed to
cope with the escalating complexity of modern programming tasks. Its template
features bring yet another new programming methodology, generic programming. This
triple heritage is both a blessing and a bane. It makes the language very powerful, but
it also means there's more to learn.

In this chapter we'll explore C++'s background further and then go over some of the
ground rules for creating C++ programs. The rest of the book teaches you to use the
C++ language, going from the modest basics of the language to the glory of
object-oriented programming (OOP) and its supporting cast of new jargon—objects,
classes, encapsulation, data hiding, polymorphism, and inheritance, then on to its
support of generic programming. (Of course, as you learn C++, these terms will be
transformed from buzzwords to the necessary vocabulary of cultivated discourse.)

Learning C++

C++ joins three separate programming traditions—the procedural language tradition,


represented by C; the object-oriented language tradition, represented by the class
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks

enhancements C++ adds to C; and generic programming, supported by C++


templates. This chapter will look into those traditions shortly. But first, let's consider
what this heritage implies about learning C++. One reason to use C++ is to avail
yourself of its object-oriented features. To do so, you need a sound background in
standard C, for that language provides the basic types, operators, control structures,
and syntax rules. So, if you already know C, you're poised to learn C++. But it's not
just a matter of learning a few more keywords and constructs. Going from C to C++
involves about as much work as learning C in the first place. Also, if you know C, you
must unlearn some programming habits as you make the transition to C++. If you don't
know C, you have to master the C components, the OOP components, and the
generic components to learn C++, but at least you may not have to unlearn
programming habits. If you are beginning to think that learning C++ may involve some
mind-stretching effort on your part, you're right. This book will guide you through the
process in a clear, helpful manner, one step at a time, so the mind-stretching will be
sufficiently gentle to leave your brain resilient.

C++ Primer Plus approaches C++ by teaching both its C basis and its new
components, so this book assumes you have no prior knowledge of C. You'll start by
learning the features C++ shares with C. Even if you know C, you may find this part of
the book a good review. Also, it points out concepts that will become important later,
and it indicates where C++ differs from C. After you are well-founded in the basics of
C, you'll add the C++ superstructure. At this point you'll learn about objects and
classes and how C++ implements them. And you will learn about templates.

This book is not intended to be a complete C++ reference; it won't explore every nook
and cranny of the language. But you will learn all the major features of the language,
including some, like templates, exceptions, and namespaces, that are more recent
additions.

Now let's take a brief look at some of C++'s background.

A Little History

Computer technology has evolved at an amazing rate during the last few decades.
Today a laptop computer can compute faster and store more information than the
mainframe computers of thirty years ago. (Quite a few programmers can recall bearing
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks

offerings of decks of punched cards to be submitted to a mighty, room-filling computer


system with a majestic 100KB of memory—not enough memory to run a good
personal computer game today.) Computer languages have evolved, too. The
changes may not be as dramatic, but they are important. Bigger, more powerful
computers spawn bigger, more complex programs which, in turn, raise new problems
in program management and maintenance.

In the 1970s, languages like C and Pascal helped usher in an era of structured
programming, a philosophy that brought some order and discipline to a field badly in
need of these qualities. Besides providing the tools for structured programming, C also
produced compact, fast-running programs along with the ability to address hardware
matters, such as managing communication ports and disk drives. These gifts helped
make C the dominant programming language in the 1980s. Meanwhile, the 1980s
witnessed the growth of a new programming paradigm: object-oriented programming,
or OOP, as embodied in languages such as SmallTalk and C++. Let's examine these
two developments (C and OOP) a bit more closely.

The C Language

In the early 1970s, Dennis Ritchie of Bell Laboratories was working on a project to
develop the UNIX operating system. (An operating system is a set of programs that
manages a computer's resources and handles its interactions with users. For example,
it's the operating system that puts the system prompt onscreen and that runs
programs for you.) For this work Ritchie needed a language that was concise, that
produced compact, fast programs, and that could control hardware efficiently.
Traditionally, programmers met these needs by using assembly language, which is
closely tied to a computer's internal machine language. However, assembly language
is a low-level language, that is, it is specific to a particular computer processor. So if
you want to move an assembly program to a different kind of computer, you may have
to completely rewrite the program using a different assembly language. It was a bit as
if each time you bought a new car, you found that the designers decided to change
where the controls went and what they did, forcing you to relearn how to drive. But
UNIX was intended to work on a variety of computer types (or platforms). That
suggested using a high-level language. A high-level language is oriented towards
problem-solving instead of towards specific hardware. Special programs called
compilers translate a high-level language to the internal language of a particular
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks

computer. Thus, you can use the same high-level language program on different
platforms by using a separate compiler for each platform. Ritchie wanted a language
that combined low-level efficiency and hardware access with high-level generality and
portability. So, building from older languages, he created C.

C Programming Philosophy

Because C++ grafts a new programming philosophy onto C, we should first take a look
at the older philosophy that C follows. In general, computer languages deal with two
concepts—data and algorithms. The data constitute the information a program uses
and processes. The algorithms are the methods the program uses (see Figure 1.1). C,
like most mainstream languages to date, is a procedural language. That means it
emphasizes the algorithm side of programming. Conceptually, procedural
programming consists of figuring out the actions a computer should take and then
using the programming language to implement those actions. A program prescribes a
set of procedures for the computer to follow to produce a particular outcome, much as
a recipe prescribes a set of procedures for a cook to follow to produce a cake.

Figure 1.1. Data + algorithms = program.


This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks

Earlier procedural languages, such as FORTRAN and BASIC, ran into organizational
problems as programs grew larger. For example, programs often use branching
statements, which route execution to one or another set of instructions depending
upon the result of some sort of test. Many older programs had such tangled routing
(called "spaghetti programming") that it was virtually impossible to understand a
program by reading it, and modifying such a program was an invitation to disaster. In
response, computer scientists developed a more disciplined style of programming
called structured programming. C includes features to facilitate this approach. For
example, structured programming limits branching (choosing which instruction to do
next) to a small set of well-behaved constructions. C incorporates these constructions
(the for loop, the while loop, the do while loop, and the if else statement) into its
vocabulary.

Top-down design was another of the new principles. The idea is to break a large
program into smaller, more manageable tasks. If one of these tasks is still too broad,
divide it into yet smaller tasks. Continue with this process until the program is
compartmentalized into small, easily programmed modules. (Organize your study.
Aargh! Well, organize your desk, your table top, your filing cabinet, and your
bookshelves. Aargh! Well, start with the desk and organize each drawer, starting with
the middle one. Hmmm, perhaps I can manage that task.) C's design facilitates this
approach, encouraging you to develop program units called functions to represent
individual task modules. As you may have noticed, the structured programming
techniques reflect a procedural mind-set, thinking of a program in terms of the actions
it performs.

Object-Oriented Programming

Although the principles of structured programming improved the clarity, reliability, and
ease of maintenance of programs, large-scale programming still remains a challenge.
Object-oriented programming (OOP) brings a new approach to that challenge. Unlike
procedural programming, which emphasizes algorithms, OOP emphasizes the data.
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks

Rather than trying to fit a problem to the procedural approach of a language, OOP
attempts to fit the language to the problem. The idea is to design data forms that
correspond to the essential features of a problem.

In C++, a class is a specification describing such a new data form, and an object is a
particular data structure constructed according to that plan. For example, a class could
describe the general properties of a corporation executive (name, title, salary, unusual
abilities, for example), while an object would represent a specific executive (Guilford
Sheepblat, vice president, $325,000, knows how to use a CONFIG.SYS file). In
general, a class defines what data are used to represent an object and the operations
that can be performed upon that data. For example, suppose you were developing a
computer drawing program capable of drawing a rectangle. You could define a class
to describe a rectangle. The data part of the specification could include such things as
the location of the corners, the height and width, the color and style of the boundary
line, and the color and pattern used to fill the rectangle. The operations part of the
specification could include methods for moving the rectangle, resizing it, rotating it,
changing colors and patterns, and copying the rectangle to another location. If you
then use your program to draw a rectangle, it will create an object according to the
class specification. That object will hold all the data values describing the rectangle,
and you can use the class methods to modify that rectangle. If you draw two
rectangles, the program will create two objects, one for each rectangle.

The OOP approach to program design is to first design classes that accurately
represent those things with which the program deals. A drawing program, for example,
might define classes to represent rectangles, lines, circles, brushes, pens, and the
like. The class definitions, recall, include a description of permissible operations for
each class, such as moving a circle or rotating a line. Then you proceed to design a
program using objects of those classes. The process of going from a lower level of
organization, such as classes, to a higher level, such as program design, is called
bottom-up programming.

There's more to OOP programming than the binding of data and methods into a class
definition. OOP, for example, facilitates creating reusable code, and that eventually
can save a lot of work. Information hiding safeguards data from improper access.
Polymorphism lets you create multiple definitions for operators and functions, with the
programming context determining which definition is used. Inheritance lets you derive
new classes from old ones. As you can see, object-oriented programming introduces
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks

many new ideas and involves a different approach to programming than does
procedural programming. Instead of concentrating on tasks, you concentrate on
representing concepts. Instead of taking a top-down programming approach, you
sometimes take a bottom-up approach. This book will guide you through all these
points with plenty of easily grasped examples.

Designing a useful, reliable class can be a difficult task. Fortunately, OOP languages
make it simple to incorporate existing classes into your own programming. Vendors
provide a variety of useful class libraries, including libraries of classes designed to
simplify creating programs for environments such as Windows or the Macintosh. One
of the real benefits of C++ is that it lets you easily reuse and adapt existing,
well-tested code.

Generic Programming

Generic programming is yet another programming paradigm supported by C++. It


shares with OOP the aim of making it simpler to reuse code and the technique of
abstracting general concepts. But while OOP emphasizes the data aspect of
programming, generic programming emphasizes the algorithmic aspect. And its focus
is different. OOP is a tool for managing large projects, while generic programming
provides tools for performing common tasks, such as sorting data or merging lists. The
term generic means to create code that is type-independent. C++ data
representations come in many types—integers, numbers with fractional parts,
characters, strings of characters, user-defined compound structures of several types.
If, for example, you wanted to sort data of these various types, you normally have to
create a separate sorting function for each type. Generic programming involves
extending the language so that you can write a function for a generic (that is, not
specified) type once, and use it for a variety of actual types. C++ templates provide a
mechanism for doing that.

C++

Like C, C++ began its life at Bell Labs, where Bjarne Stroustrup developed the
language in the early 1980s. In his own words, "C++ was designed primarily so that
my friends and I would not have to program in assembler, C, or various modern
This document was created by an unregistered ChmMagic, please go to http://www.bisenter.com to register it. Thanks

high-level languages. Its main purpose was to make writing good programs easier and
more pleasant for the individual programmer" (Bjarne Stroustrup, The C++
Programming Language. Third Edition. Reading, MA: Addison-Wesley Publishing
Company, 1997).

Stroustrup was more concerned with making C++ useful than with enforcing particular
programming philosophies or styles. Real programming needs are more important
than theoretical purity in determining C++ language features. Stroustrup based C++
on C because of C's brevity, its suitability to system programming, its widespread
availability, and its close ties to the UNIX operating system. C++'s OOP aspect was
inspired by a computer simulation language called Simula67. Stroustrup added OOP
features and generic programming support to C without significantly changing the C
component. Thus C++ is a superset of C, meaning that any valid C program is a valid
C++ program, too. There are some minor discrepancies, but nothing crucial. C++
programs can use existing C software libraries. Libraries are collections of
programming modules that you can call up from a program. They provide proven
solutions to many common programming problems, thus saving you much time and
effort. This has helped the spread of C++.

The name C++ comes from the C increment operator ++, which adds 1 to the value of
a variable. The name C++ correctly suggests an augmented version of C.

A computer program translates a real-life problem into a series of actions to be taken


by a computer. While the OOP aspect of C++ gives the language the ability to relate to
concepts involved in the problem, the C part of C++ gives the language the ability to
get close to the hardware (see Figure 1.2). This combination of abilities has helped
the spread of C++. It may also involve a mental shift of gears as you turn from one
aspect of a program to another. (Indeed, some OOP purists regard adding OOP
features to C akin to adding wings to a pig, albeit a lean, efficient pig.) Also, because
C++ grafts OOP onto C, you can ignore C++'s object-oriented features. But you'll miss
a lot if that's all you do.

Figure 1.2. C++ duality.


Another Random Scribd Document
with Unrelated Content
there. Yé climbed all the way to the top of the Morne de la Croix without
suspecting anything. When he got there the little boy put one of his ears out of
Yé's pocket,—so as to hear everything the Good-God would say.
This time he was very angry,—the Bon-Dié: he spoke very crossly; he scolded Yé
a great deal. But he was so kind for all that,—he was so generous to good-for-
nothing Yé, that he took the pains to repeat the words over and over again for
him:—"Tam ni pou tam ni bé."... And this time the Bon-Dié was not talking to no
purpose: there was somebody there well able to remember what he said. Ti
Fonté made the most of his chance;—he sharpened that little tongue of his; he
thought of his mamma and all his little brothers and sisters dying of hunger down
below. As for his father, Yé did as he had done before—stuffed himself with all
the green fruit he could find.
The moment Yé got home and took off his coat, Ti Fonté jumped out, plapp!—
and ran to his mamma, and whispered:—
—"Mamma, get ready a nice, big dinner!—we are going to have it all to ourselves
to-day: the Good-God didn't talk for nothing,—I heard every word he said!"
Then the mother got ready a nice calalou-crabe, a tonton-banane, a matété-
cirique,—several calabashes of couss-caye, two régimes-figues (bunches of small
bananas),—in short, a very fine dinner indeed, with a chopine of tafia to wash it
all well down.
The Devil felt as sure of himself that day as he had always felt, and got up the
moment everything was ready. But Ti Fonté got up too, and yelled out just as
loud as he could:—-"Tam ni pou tam ni bé!"
At once the Devil gave a scream so loud that it could be heard right down to the
bottom of hell,—and he fell dead.
Meanwhile, Yé, like the old fool he was, kept trying to say what the Bon-Dié had
told him, and could only mumble:—
—"Anni toqué Diabe-là cagnan!"
He would never have been able to do anything;—and his wife had a great mind
just to send him to bed at once, instead of letting him sit down to eat all those
nice things. But she was a kind-hearted soul; and so she let Yé stay and eat with
the children, though he did not deserve it. And they all ate and ate, and kept on
eating and filling themselves until daybreak—pauv piti!
But during this time the Devil had begun to smell badly and he had become
swollen so big that Yé found he could not move him. Still, they knew they must
get him out of the way somehow. The children had eaten so much that they were
all full of strength—yo tè plein lafòce; and Yé got a rope and tied one end round
the Devil's foot; and then he and the children—all pulling together—managed to
drag the Devil out of the cabin and into the bushes, where they left him just like
a dead dog. They all felt themselves very happy to be rid of that old Devil.

But some days after old good-for-nothing Yé went off to hunt for birds. He had a
whole lot of arrows with him. He suddenly remembered the Devil, and thought
he would like to take one more look at him. And he did.
Fouinq! what a sight! The Devil's belly had swelled up like a morne: it was yellow
and blue and green,—looked as if it was going to burst. And Yé, like the old fool
he always was, shot an arrow up in the air, so that it fell down and stuck into the
Devil's belly. Then he wanted to get the arrow, and he climbed up on the Devil,
and pulled and pulled till he got the arrow out. Then he put the point of the
arrow to his nose,—just to see what sort of a smell dead Devils had.
The moment he did that, his nose swelled up as big as the refinery-pot of a
sugar-plantation.

Yé could scarcely walk for the weight of his nose; but he had to go and see the
Bon-Dié again. The Bon-Dié said to him:—
—"Ah! Yé, my poor Yé, you will live and die a fool!—you are certainly the biggest
fool in the whole world!... Still, I must try to do something for you;—I'll help you
anyhow to get rid of that nose!... I'll tell you how to do it. To-morrow morning,
very early, get up and take a big taya [whip], and beat all the bushes well, and
drive all the birds to the Roche de la Caravelle. Then you must tell them that I,
the Bon-Dié, want them to take off their bills and feathers, and take a good bath
in the sea. While they are bathing, you can choose a nose for yourself out of the
heap of bills there."
Poor Yé did just as the Good-God told him; and while the birds were bathing, he
picked out a nose for himself from the heap of beaks,—and left his own refinery-
pot in its place.
The nose he took was the nose of the coulivicou.[58] And that is why the
coulivicou always looks so much ashamed of himself even to this day.

[54]In the patois, "yon rafale yche"—"a whirlwind of children."


[55]In the original:—"Y té ka monté assous tabe-là, épi y té ka fai caca adans toutt plats-à, adans
toutt zassiett-là."
[56]A peaklet rising above the verge of the ancient crater now filled with water.
[57]The great field-rat of Martinique is, in Martinique folklore, the symbol of all cunning, and
probably merits its reputation.
[58]The coulivicou, or "Colin Vicou," is a Martinique bird with a long meagre body, and an
enormous bill. It has a very tristful and taciturn expression.... Maig conm yon coulivicou, "thin as
a coulivicou," is a popular comparison for the appearance of anybody much reduced by sickness.

III

... Poor Yé!—you still live for me only too vividly outside of those strange folk-
tales of eating and of drinking which so cruelly reveal the long slave-hunger of
your race. For I have seen you cutting cane on peak slopes above the clouds;—I
have seen you climbing from plantation to plantation with your cutlass in your
hand, watching for snakes as you wander to look for work, when starvation
forces you to obey a master, though born with the resentment of centuries
against all masters;—I have seen you prefer to carry two hundred-weight of
bananas twenty miles to market, rather than labor in the fields;—I have seen you
ascending through serpent-swarming woods to some dead crater to find a
cabbage-palm,—and always hungry,—and always shiftless! And you are still a
great fool, poor Yé!—and you have still your swarm of children,—your rafale
yche,—and they are famished; for you have taken into your ajoupa a Devil who
devours even more than you can earn,—even your heart, and your splendid
muscles, and your poor artless brain,—the Devil Tafia!... And there is no Bon-Dié
to help you rid yourself of him now: for the only Bon-Dié you ever really had,
your old creole master, cannot care for you any more, and you cannot care for
yourself. Mercilessly moral, the will of this enlightened century has abolished
forever that patriarchal power which brought you up strong and healthy on
scanty fare, and scourged you into its own idea of righteousness, yet kept you
innocent as a child of the law of the struggle for life. But you feel that law now;—
you are a citizen of the Republic! you are free to vote, and free to work, and free
to starve if you prefer it, and free to do evil and suffer for it;—and this new
knowledge stupefies you so that you have almost forgotten how to laugh!
LYS

It is only half-past four o'clock: there is the faintest blue light of


beginning day,—and little Victoire already stands at the bedside with my
wakening cup of hot black fragrant coffee. What! so early?... Then with
a sudden heart-start I remember this is my last West Indian morning.
And the child—her large timid eyes all gently luminous—is pressing
something into my hand.
Two vanilla beans wrapped in a morsel of banana-leaf,—her poor little
farewell gift!...
Other trifling souvenirs are already packed away. Almost everybody that
knows me has given me something. Manm-Robert brought me a tiny
packet of orange-seeds,—seeds of a "gift-orange": so long as I can keep
these in my vest-pocket I will never be without money. Cyrillia brought
me a package of bouts, and a pretty box of French matches, warranted
inextinguishable by wind. Azaline, the blanchisseuse, sent me a little pocket
looking-glass. Cerbonnie, the màchanne, left a little cup of guava jelly for me last
night. Mimi—dear child!—brought me a little paper dog! It is her best toy; but
those gentle black eyes would stream with tears if I dared to refuse it.... Oh,
Mimi! what am I to do with a little paper dog? And what am I to do with the
chocolate-sticks and the cocoanuts and all the sugar-cane and all the cinnamon-
apples?...

II

... Twenty minutes past five by the clock of the Bourse. The hill shadows are
shrinking back from the shore;—the long wharves reach out yellow into the sun;
—the tamarinds of the Place Bertin, and the pharos for half its height, and the
red-tiled roofs along the bay are catching the glow. Then, over the light-house—
on the outermost line depending from the southern yard-arm of the semaphore—
a big black ball suddenly runs up like a spider climbing its own thread.... Steamer
from the South! The packet has been sighted. And I have not yet been able to
pack away into a specially purchased wooden box all the fruits and vegetable
curiosities and odd little presents sent to me. If Radice the boatman had not
come to help me, I should never be able to get ready; for the work of packing is
being continually interrupted by friends and acquaintances coming to say good-
bye. Manm-Robert brings to see me a pretty young girl—very fair, with a violet
foulard twisted about her blonde head. It is little Basilique, who is going to make
her pouémiè communion. So I kiss her, according to the old colonial custom,
once on each downy cheek;—and she is to pray to Notre Dame du Bon Port that
the ship shall bear me safely to far-away New York.
And even then the steamer's cannon-call shakes over the town and into the hills
behind us, which answer with all the thunder of their phantom artillery.

III

... There is a young white lady, accompanied by an aged negress, already waiting
on the south wharf for the boat;—evidently she is to be one of my fellow-
passengers. Quite a pleasing presence: slight graceful figure,—a face not
precisely pretty, but delicate and sensitive, with the odd charm of violet eyes
under black eye-brows....
A friend who comes to see me off tells me all about her. Mademoiselle Lys is
going to New York to be a governess,—to leave her native island forever. A story
sad enough, though not more so than that of many a gentle creole girl. And she
is going all alone, for I see her bidding good-bye to old Titine,—kissing her. "Adié
encò, chè;—Bon-Dié ké béni ou!" sobs the poor servant, with tears streaming
down her kind black face. She takes off her blue shoulder-kerchief, and waves it
as the boat recedes from the wooden steps.

... Fifteen minutes later, Mademoiselle and I find ourselves under the awnings
shading the saloon-deck of the Guadeloupe. There are at least fifty passengers,—
many resting in chairs, lazy-looking Demerara chairs with arm-supports
immensely lengthened so as to form rests for the lower limbs. Overhead,
suspended from the awning-frames, are two tin cages containing parrots;—and I
see two little greenish monkeys, no bigger than squirrels, tied to the wheel-
hatch,—two sakiwinkis. These are from the forests of British Guiana. They keep
up a continual thin sharp twittering, like birds,—all the while circling, ascending,
descending, retreating or advancing to the limit of the little ropes attaching them
to the hatch.
The Guadeloupe has seven hundred packages to deliver at St. Pierre: we have
ample time,—Mademoiselle Violet-Eyes and I,—to take one last look at the "Pays
des Revenants."
I wonder what her thoughts are, feeling a singular sympathy for her,—for I am in
that sympathetic mood which the natural emotion of leaving places and persons
one has become fond of, is apt to inspire. And now at the moment of my going,—
when I seem to understand as never before the beauty of that tropic Nature, and
the simple charm of the life to which I am bidding farewell,—the question comes
to me: "Does she not love it all as I do,—nay, even much more, because of that
in her own existence which belongs to it?" But as a child of the land, she has
seen no other skies,—fancies, perhaps, there may be brighter ones....
... Nowhere on this earth, Violet-Eyes!—nowhere beneath this sun!... Oh! the
dawnless glory of tropic morning!—the single sudden leap of the giant light over
the purpling of a hundred peaks,—over the surging of the mornes! And the early
breezes from the hills,—all cool out of the sleep of the forests, and heavy with
vegetal odors thick, sappy, savage-sweet!—and the wild high winds that run
ruffling and crumpling through the cane of the mountain slopes in storms of
papery sound!—
And the mighty dreaming of the woods,—green-drenched with silent pouring of
creepers,—dashed with the lilac and yellow and rosy foam of liana flowers!—
And the eternal azure apparition of the all-circling sea,—that as you mount the
heights ever appears to rise perpendicularly behind you,—that seems, as you
descend, to sink and flatten before you!—
And the violet velvet distances of evening;—and the swaying of palms against the
orange-burning,—when all the heaven seems filled with vapors of a molten
sun!...

IV

How beautiful the mornes and azure-shadowed hollows in the jewel clearness of
this perfect morning! Even Pelée wears only her very lightest head-dress of
gauze; and all the wrinklings of her green robe take unfamiliar tenderness of tint
from the early sun. All the quaint peaking of the colored town—sprinkling the
sweep of blue bay with red and yellow and white-of-cream—takes a sharpness in
this limpid light as if seen through a diamond lens; and there above the living
green of the familiar hills I can see even the faces of the statues—the black
Christ on his white cross, and the White Lady of the Morne d'Orange—among
curving palms.... It is all as though the island were donning its utmost possible
loveliness, exerting all its witchery,—seeking by supremest charm to win back
and hold its wandering child,—Violet-Eyes over there!... She is looking too.
I wonder if she sees the great palms of the Voie du Parnasse,—curving far away
as to bid us adieu, like beautiful bending women. I wonder if they are not trying
to say something to her; and I try myself to fancy what that something is:—
—"Child, wilt thou indeed abandon all who love thee!... Listen!—'tis a dim grey
land thou goest unto,—a land of bitter winds,—a land of strange gods,—a land of
hardness and barrenness, where even Nature may not live through half the
cycling of the year! Thou wilt never see us there.... And there, when thou shalt
sleep thy long sleep, child—that land will have no power to lift thee up;—vast
weight of stone will press thee down forever;—until the heavens be no more thou
shalt not awake!... But here, darling, our loving roots would seek for thee, would
find thee: thou shouldst live again!—we lift, like Aztec priests, the blood of hearts
to the Sun."...

... It is very hot.... I hold in my hand a Japanese paper-fan with a design upon it
of the simplest sort: one jointed green bamboo, with a single spurt of sharp
leaves, cutting across a pale blue murky double streak that means the horizon
above a sea. That is all. Trivial to my Northern friends this design might seem;
but to me it causes a pleasure bordering on pain.... I know so well what the artist
means; and they could not know, unless they had seen bamboos,—and bamboos
peculiarly situated. As I look at this fan I know myself descending the Morne
Parnasse by the steep winding road; I have the sense of windy heights behind
me, and forest on either hand, and before me the blended azure of sky and sea
with one bamboo-spray swaying across it at the level of my eyes. Nor is this all;
—I have the every sensation of the very moment,—the vegetal odors, the mighty
tropic light, the warmth, the intensity of irreproducible color.... Beyond a doubt,
the artist who dashed the design on this fan with his miraculous brush must have
had a nearly similar experience to that of which the memory is thus aroused in
me, but which I cannot communicate to others.
... And it seems to me now that all which I have tried to write about the Pays des
Revenants can only be for others, who have never beheld it,—vague like the
design upon this fan.

VI

Brrrrrrrrrrr!... The steam-winch is lifting the anchor; and the Guadeloupe


trembles through every plank as the iron torrent of her chain-cable rumbles
through the hawse-holes.... At last the quivering ceases;—there is a moment's
silence; and Violet-Eyes seems trying to catch a last glimpse of her faithful bonne
among the ever-thickening crowd upon the quay.... Ah! there she is—waving her
foulard. Mademoiselle Lys is waving a handkerchief in reply....
Suddenly the shock of the farewell gun shakes heavily through our hearts, and
over the bay,—where the tall mornes catch the flapping thunder, and buffet it
through all their circle in tremendous mockery. Then there is a great whirling and
whispering of whitened water behind the steamer—another,—another; and the
whirl becomes a foaming stream: the mighty propeller is playing!.... All the blue
harbor swings slowly round;—and the green limbs of the land are pushed out
further on the left, shrink back upon the right;—and the mountains are moving
their shoulders. And then the many-tinted façades,—and the tamarinds of the
Place Bertin,—and the light-house,—and the long wharves with their throng of
turbaned women,—and the cathedral towers,—and the fair palms,—and the
statues of the hills,—all veer, change place, and begin to float away... steadily,
very swiftly.
Farewell, fair city,—sun-kissed city,—many-fountained city!—dear yellow-
glimmering streets,—white pavements learned by heart,—and faces ever looked
for,—and voices ever loved! Farewell, white towers with your golden-throated
bells!—farewell, green steeps, bathed in the light of summer everlasting!—craters
with your coronets of forest!—bright mountain paths upwinding 'neath pomp of
fern and angelin and feathery bamboo!—and gracious palms that drowse above
the dead! Farewell, soft-shadowing majesty of valleys unfolding to the sun,—
green golden cane-fields ripening to the sea!...

... The town vanishes. The island slowly becomes a green silhouette. So might
Columbus first have seen it from the deck of his caravel,—nearly four hundred
years ago. At this distance there are no more signs of life upon it than when it
first became visible to his eyes: yet there are cities there,—and toiling,—and
suffering,—and gentle hearts that knew me.... Now it is turning blue,—the
beautiful shape!—becoming a dream....

VII

And Dominica draws nearer,—sharply massing her hills against the vast light in
purple nodes and gibbosities and denticulations. Closer and closer it comes, until
the green of its heights breaks through the purple here and there,—in flashings
and ribbings of color. Then it remains as if motionless a while;—then the green
lights go out again,—and all the shape begins to recede sideward towards the
south.
... And what had appeared a pearl-grey cloud in the north slowly reveals itself as
another island of mountains,—hunched and horned and mammiform:
Guadeloupe begins to show her double profile. But Martinique is still visible;—
Pelée still peers high over the rim of the south.... Day wanes;—the shadow of the
ship lengthens over the flower-blue water. Pelée changes aspect at last,—turns
pale as a ghost,—but will not fade away....
... The sun begins to sink as he always sinks to his death in the tropics,—swiftly,
—too swiftly!—and the glory of him makes golden all the hollow west,—and
bronzes all the flickering wave-backs. But still the gracious phantom of the island
will not go,—softly haunting us through the splendid haze. And always the tropic
wind blows soft and warm;—there is an indescribable caress in it! Perhaps some
such breeze, blowing from Indian waters, might have inspired that prophecy of
Islam concerning the Wind of the Last Day,—that "Yellow Wind, softer than silk,
balmier than musk,"—which is to sweep the spirits of the just to God in the great
Winnowing of Souls....
Then into the indigo night vanishes forever from my eyes the ghost of Pelée; and
the moon swings up,—a young and lazy moon, drowsing upon her back, as in a
hammock.... Yet a few nights more, and we shall see this slim young moon erect,
—gliding upright on her way,—coldly beautiful like a fair Northern girl.

VIII

And ever through tepid nights and azure days the Guadeloupe rushes on,—her
wake a river of snow beneath the sun, a torrent of fire beneath the stars,—
steaming straight for the North.
Under the peaking of Montserrat we steam,—beautiful Montserrat, all softly
wrinkled like a robe of greenest velvet fallen from the waist!—breaking the pretty
sleep of Plymouth town behind its screen of palms... young palms, slender and
full of grace as creole children are;—
And by tall Nevis, with her trinity of dead craters purpling through ocean-haze;—
by clouded St. Christopher's mountain-giant;—past ghostly St. Martin's, far-
floating in fog of gold, like some dream of the Saint's own Second Summer;—
Past low Antigua's vast blue harbor,—shark-haunted, bounded about by huddling
of little hills, blue and green.
Past Santa Cruz, the "Island of the Holy Cross,"—all radiant with verdure though
well nigh woodless,—nakedly beautiful in the tropic light as a perfect statue;—
Past the long cerulean reaching and heaping of Porto Rico on the left, and past
hopeless St. Thomas on the right,—old St. Thomas, watching the going and the
coming of the commerce that long since abandoned her port,—watching the
ships once humbly solicitous for patronage now turning away to the Spanish rival,
like ingrates forsaking a ruined patrician;—
And the vapory Vision of, St. John;—and the grey ghost of Tortola,—and further,
fainter, still more weirdly dim, the aureate phantom of Virgin Gorda.
IX

Then only the enormous double-vision of sky and sea.


The sky: a cupola of blinding blue, shading down and paling into spectral green
at the rim of the world,—and all fleckless, save at evening. Then, with sunset,
comes a light gold-drift of little feathery cloudlets into the West,—stippling it as
with a snow of fire.
The sea: no flower-tint may now make my comparison for the splendor of its
lucent color. It has shifted its hue;—for we have entered into the Azure Stream: it
has more than the magnificence of burning cyanogen....
But, at night, the Cross of the South appears no more. And other changes come,
as day succeeds to day,—a lengthening of the hours of light, a longer lingering of
the after-glow,—a cooling of the wind. Each morning the air seems a little cooler,
a little rarer;—each noon the sky looks a little paler, a little further away—always
heightening, yet also more shadowy, as if its color, receding, were dimmed by
distance,—were coming more faintly down from vaster altitudes.

... Mademoiselle is petted like a child by the lady passengers. And every man
seems anxious to aid in making her voyage a pleasant one. For much of which, I
think, she may thank her eyes!

A dim morning and chill;—blank sky and sunless waters: the sombre heaven of
the North with colorless horizon rounding in a blind grey sea.... What a sudden
weight comes to the heart with the touch of the cold mist, with the spectral
melancholy of the dawn;—and then what foolish though irrepressible yearning for
the vanished azure left behind!
... The little monkeys twitter plaintively, trembling in the chilly air. The parrots
have nothing to say: they look benumbed, and sit on their perches with eyes
closed.
... A vagueness begins to shape itself along the verge of the sea, far to port: that
long heavy clouding which indicates the approach of land. And from it now floats
to us something ghostly and frigid which makes the light filmy and the sea
shadowy as a flood of dreams,—the fog of the Jersey coast.
At once the engines slacken their respiration. The Guadeloupe begins to utter her
steam-cry of warning,—regularly at intervals of two minutes,—for she is now in
the track of all the ocean vessels. And from far away we can hear a heavy
knelling,—the booming of some great fog-bell.
... All in a white twilight. The place of the horizon has vanished;—we seem ringed
in by a wall of smoke.... Out of this vapory emptiness—very suddenly—an
enormous steamer rushes, towering like a hill—passes so close that we can see
faces, and disappears again, leaving the sea heaving and frothing behind her.

... As I lean over the rail to watch the swirling of the wake, I feel something
pulling at my sleeve: a hand,—a tiny black hand,—the hand of a sakiwinki. One
of the little monkeys, straining to the full length of his string, is making this dumb
appeal for human sympathy;—the bird-black eyes of both are fixed upon me with
the oddest look of pleading. Poor little tropical exiles! I stoop to caress them; but
regret the impulse a moment later: they utter such beseeching cries when I find
myself obliged to leave them again alone!...
... Hour after hour the Guadeloupe glides on through the white gloom,—
cautiously, as if feeling her way; always sounding her whistle, ringing her bells,
until at last some brown-winged bark comes flitting to us out of the mist, bearing
a pilot.... How strange it must all seem to Mademoiselle who stands so silent
there at the rail!—how weird this veiled world must appear to her, after the
sapphire light of her own West Indian sky, and the great lazulite splendor of her
own tropic sea!
But a wind comes;—it strengthens,—begins to blow very cold. The mists thin
before its blowing; and the wan blank sky is all revealed again with livid horizon
around the heaving of the iron-grey sea.

... Thou dim and lofty heaven of the North,—grey sky of Odin,—bitter thy winds
and spectral all thy colors!—they that dwell beneath thee know not the glory of
Eternal Summer's green,—the azure splendor of southern day!—but thine are the
lightnings of Thought illuminating for human eyes the interspaces between sun
and sun. Thine the generations of might,—the strivers, the battlers,—the men
who make Nature tame!—thine the domain of inspiration and achievement,—the
larger heroisms, the vaster labors that endure, the higher knowledge, and all the
witchcrafts of science!...

But in each one of us there lives a mysterious Something which is Self, yet also
infinitely more than Self,—incomprehensibly multiple,—the complex total of
sensations, impulses, timidities belonging to the unknown past. And the lips of
the little stranger from the tropics have become all white, because that
Something within her,—ghostly bequest from generations who loved the light and
rest and wondrous color of a more radiant world,—now shrinks all back about her
girl's heart with fear of this pale grim North.... And lo!—opening mile-wide in
dream-grey majesty before us,—reaching away, through measureless mazes of
masting, into remotenesses all vapor-veiled,—the mighty perspective of New York
harbor!...

Thou knowest it not, this gloom about us, little maiden;—'tis only a magical dusk
we are entering,—only that mystic dimness in which miracles must be wrought!...
See the marvellous shapes uprising,—the immensities, the astonishments! And
other greater wonders thou wilt behold in a little while, when we shall have
become lost to each other forever in the surging of the City's million-hearted
life!... 'Tis all shadow here, thou sayest?—Ay, 'tis twilight, verily, by contrast with
that glory out of which thou camest, Lys—twilight only,—but the Twilight of the
Gods!... Adié, chè!—Bon-Dié ké bént ou!...

APPENDIX—SOME CREOLE MELODIES

More than a hundred years ago Thibault de Chanvallon expressed his


astonishment at the charm and wonderful sense of musical rhythm characterizing
the slave-songs and slave-dances of Martinique. The rhythmical sense of the
negroes especially impressed him. "I have seen," he writes, "seven or eight
hundred negroes accompanying a wedding-party to the sound of song. They
would all leap up in the air and come down together;—the movement was so
exact and general that the noise of their fall made but a single sound."
An almost similar phenomenon may be witnessed any Carnival season in St.
Pierre,—while the Devil makes his nightly round, followed by many hundred boys
clapping hands and leaping in chorus. It may also be observed in the popular
malicious custom of the pillard, or, in creole, piyà. Some person whom it is
deemed justifiable and safe to annoy, may suddenly find himself followed in the
street by a singing chorus of several hundred, all clapping hands and dancing or
running in perfect time, so that all the bare feet strike the ground together. Or
the pillard-chorus may even take up its position before the residence of the party
disliked, and then proceed with its performance. An example of such a pillard is
given further on, in the song entitled Loéma tombé. The improvisation by a single
voice begins the pillard,—which in English might be rendered as follows:—
(Single voice) You little children there!—you who were by the
river-side!
Tell me truly this:—Did you see Loéma fall?
Tell me truly this—
(Chorus, opening) Did you see Loéma fall?
(Single voice) Tell me truly this—
(Chorus) Did you see Loéma fall?
(Single voice, more rapidly) Tell me truly this—
(Chorus, more quickly) Loéma fall!
(Single voice) Tell me truly this—
(Chorus) Loéma fall!
(Single voice) Tell me truly this—
(Chorus, always more quickly, and more loudly, all the hands clapping together
like a fire of musketry) Loéma fall! etc.
The same rhythmic element characterizes many of the games and round dances
of Martinique children;—but, as a rule, I think it is perceptible that the sense of
time is less developed in the colored children than in the black.
The other melodies which are given as specimens of Martinique music show less
of the African element,—the nearest approach to it being in Tant sirop; but all are
probably creations of the mixed race. Marie-Clémence is a Carnival satire
composed not more than four years ago. To-to-to is very old—dates back,
perhaps, to the time of the belles-affranchies. It is seldom sung now except by
survivors of the old régime: the sincerity and tenderness of the emotion that
inspired it—the old sweetness of heart and simplicity of thought,—are passing
forever away.
To my friend, Henry Edward Krehbiel, the musical lecturer and critic,—at once
historian and folklorist in the study of race-music,—and to Mr. Frank van der
Stucken, the New York musical composer, I owe the preparation of these four
melodies for voice and piano-forte. The arrangements of To-to-to and Loéma
tombé are Mr. Van der Stucken's.

"TO-TO-TO"

(Creole werds)
MARIE-CLÉMENCE

(Creole words)
TANT SIROP EST DOUX

(Negro-French)
LOÉMA TOMBÉ

(Creole words)
*** END OF THE PROJECT GUTENBERG EBOOK TWO YEARS IN THE
FRENCH WEST INDIES ***

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


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE 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.
1.C. The Project Gutenberg 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:
This eBook is for 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
with active links or 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
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

You might also like