0% found this document useful (0 votes)
4 views

C Data Structures A Laboratory Course Stefan Brandle instant download

The document is a promotional piece for various educational ebooks, particularly focusing on 'C Data Structures: A Laboratory Course' by Stefan Brandle and others. It outlines the structure and content of the book, which includes practical exercises and applications of data structures using C++. Additionally, it provides information about the publisher and resources available for students and instructors, emphasizing a hands-on approach to learning data structures.

Uploaded by

jandilohner
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

C Data Structures A Laboratory Course Stefan Brandle instant download

The document is a promotional piece for various educational ebooks, particularly focusing on 'C Data Structures: A Laboratory Course' by Stefan Brandle and others. It outlines the structure and content of the book, which includes practical exercises and applications of data structures using C++. Additionally, it provides information about the publisher and resources available for students and instructors, emphasizing a hands-on approach to learning data structures.

Uploaded by

jandilohner
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 61

C Data Structures A Laboratory Course Stefan

Brandle pdf download

https://ebookname.com/product/c-data-structures-a-laboratory-
course-stefan-brandle/

Get Instant Ebook Downloads – Browse at https://ebookname.com


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

Data Structures Using C 2nd Edition A. K. Sharma

https://ebookname.com/product/data-structures-using-c-2nd-
edition-a-k-sharma/

C Plus Data Structures Third Edition Nell Dale

https://ebookname.com/product/c-plus-data-structures-third-
edition-nell-dale/

ADTs Data Structures and Problem Solving with C 2nd


Edition Nyhoff

https://ebookname.com/product/adts-data-structures-and-problem-
solving-with-c-2nd-edition-nyhoff/

Cyrano de Bergerac Webster s Spanish Thesaurus Edition


Edmond Rostand

https://ebookname.com/product/cyrano-de-bergerac-webster-s-
spanish-thesaurus-edition-edmond-rostand/
Rehab Notes Davis Notes 1st Edition Ellen A. Hillegass

https://ebookname.com/product/rehab-notes-davis-notes-1st-
edition-ellen-a-hillegass/

Social Sciences The Big Issues 2003 1st Edition Kath


Woodward

https://ebookname.com/product/social-sciences-the-big-
issues-2003-1st-edition-kath-woodward/

Introduction to Programming Languages 1st Edition


Arvind Kumar Bansal (Author)

https://ebookname.com/product/introduction-to-programming-
languages-1st-edition-arvind-kumar-bansal-author/

NET Framework Standard Library Annotated Reference Brad


Abrams

https://ebookname.com/product/net-framework-standard-library-
annotated-reference-brad-abrams/

Experimental Buddhism Innovation and Activism in


Contemporary Japan Topics in Contemporary Buddhism 5
John K. Nelson

https://ebookname.com/product/experimental-buddhism-innovation-
and-activism-in-contemporary-japan-topics-in-contemporary-
buddhism-5-john-k-nelson/
Neither Dead Nor Red Civil Defense and American
Political Development During the Early Cold War 1st
Edition Andrew Grossman

https://ebookname.com/product/neither-dead-nor-red-civil-defense-
and-american-political-development-during-the-early-cold-war-1st-
edition-andrew-grossman/
++ Third Edition
C
Data Structures
A Laboratory Course

Stefan Brandle
Taylor University

Jonathan Geisler
Taylor University

James Robergé

David Whittington
Filtro Systems, Inc.

JONES AND BARTLETT PUBLISHERS


Sudbury, Massachusetts
BOSTON TORONTO LONDON SINGAPORE
World Headquarters
Jones and Bartlett Publishers
40 Tall Pine Drive
Sudbury, MA 01776
978-443-5000
info@jbpub.com
www.jbpub.com
Jones and Bartlett Publishers Canada
6339 Ormindale Way
Mississauga, Ontario L5V 1J2
Canada
Jones and Bartlett Publishers International
Barb House, Barb Mews
London W6 7PA
United Kingdom

Jones and Bartlett's books and products are available through most bookstores and online booksellers.
To contact Jones and Bartlett Publishers directly, call 800-832-0034, fax 978-443-8000, or visit our website
www.jbpub.com.

Substantial discounts on bulk quantities of Jones and Bartlett's publications are available to
corporations, professional associations, and other qualified organizations. For details and specific discount
information, contact the special sales department at Jones and Bartlett via the above contact information or
send an email to specialsales@jbpub.com.

Copyright © 2009 by Jones and Bartlett Publishers, LLC

ISBN-13: 978-0-7637-5564-5

All rights reserved. No part of the material protected by this copyright may be reproduced or utilized in
any form, electronic or mechanical, including photocopying, recording, or by any information storage and
retrieval system, without written permission from the copyright owner.

Production Credits
Acquisitions Editor: Tim Anderson
Production Director: Amy Rose
Editorial Assistant: Melissa Elmore
Senior Marketing Manager: Andrea DeFronzo
Manufacturing Buyer: Therese Connell
Composition: Northeast Compositors
Cover Design: Kate Ternullo
Cover Image: © Cocota Anca/ShutterStock, Inc.
Printing and Binding: Courier Stoughton
Cover Printing: Courier Stoughton

6048
Printed in the United States of America
12 11 10 09 08 10 9 8 7 6 5 4 3 2 1
To Christina, Anna, and Esther, for giving me the time to work on this.
—Stefan Brandle

To the women in my life. Thanks for the great deal of understanding with so
little payback time.
—Jonathan Geisler

To Michael, for letting me share in his creativity.


—James Robergé

To my family and to Melissa.


—David Whittington
contents
Preface

1 Text ADT
Focus: Implement an ADT using a C++ class, introduce a number of
foundational C++ concepts used in ADT implementation, and an
array implementation of a delimited character string
Application: Lexical analysis

2 BlogEntry ADT
Focus: Implement a blog entry class and continue introduction of
foundational C++ concepts used in ADT implementation
Application: Generate an HTML representation of a data structure's contents

3 Array Implementation of the List ADT


Focus: Array implementation of a list
Application: Analyzing DNA sequences

4 Ordered List ADT


Focus: Array implementation of an ordered list using inheritance
Application: Assembling messages in a packet switching network

5 Singly Linked List Implementation of the List ADT


Focus: Singly linked list implementation of a list
Application: Slide show program

6 Stack ADT
Focus: Array and singly linked list implementations of a stack
Application: Evaluating postfix arithmetic expressions

7 Queue ADT
Focus: Array and singly linked list implementations of a queue
Application: Simulating the flow of customers through a line

8 Expression Tree ADT


Focus: Linked implementation of an expression tree
Application: Logic circuits

9 Binary Search Tree ADT


Focus: Linked implementation of a binary search tree
Application: Indexed accounts database

10 Hash Table ADT


Focus: Hash table implementation with chaining
Application: Development of a perfect hash

11 Heap ADT
Focus: Array implementation of a heap
Application: Simulating the flow of tasks in an operating system using a
priority queue

12 Weighted Graph ADT


Focus: Adjacency matrix implementation of the Weighted Graph ADT
Application: Computation of shortest paths

13 Performance Evaluation
Focus: Determining execution times
Application: Analyzing the execution times of sorting and searching routines
preface
Preface to the Third Edition

We have used James Robergé's laboratory manual for eight years at Taylor
University. The approach and style of the original manual made it an extremely
effective teaching tool. In 2002, we were given the privilege of updating the first
edition to reflect changes in C++ and to add some new material.
It is now time for a third edition. Perhaps most significantly, all the worksheet
pages—which comprised a high percentage of the book—were moved into a set
of online supplements that instructors and students can print as needed. The
appendix material is now widely available online from multiple sources.
We discovered that many of those using the book are now using it for more
advanced courses such as Data Structures and Algorithms. A major reason for
this is that many universities have switched the second computer science course
(CS2, sometimes also called Data Structures) from C++ to Java. Given that the
target audience has shifted somewhat, and that students using the lab book have
probably already encountered Object-Oriented Programming, we chose to
increase the level of C++ and data structure sophistication. However, we ensured
that the book is still very usable for CS2—which is where we continue to use it.
Aspects of the second edition were out of date because of changes in the C++
language. Also, compilers have caught up enough with newer C++ standards that
we can safely use some of the features that either did not exist previously, or
were not reliably supported by enough common compilers. For example, the use
of typename instead of class in templates.
Our goal to be true to Jim Robergé's original vision of the laboratory
experience remains, but we also recognize that the book is no longer necessarily
used with the classic closed lab. As a consequence, we modified our
nomenclature. For instance, In-Lab Exercises are now called Programming
Exercises. Post-Lab Exercises are now called Analysis Exercises. These can still
be used as in-lab/post-lab exercises with a closed lab, but the naming more
accurately reflects the reality that these labs can be used equally well as regular
weekly programming assignments in a non-laboratory course.

Overview of Changes

Each chapter has been organized into Objectives, ADT Overview, C++
Concepts Overview, ADT Specification, Implementation Notes, Compilation
Directions, and Testing. Then, there are three Programming Exercises and two
Analysis Exercises.
We also made the following significant changes:

• Introduced a configuration file, config.h, that allows students to control


which ADT extensions are used by the test program. We feel that this
method is cleaner and a better example for students than the laborious
uncommenting and recommenting that was required.

• Error handling is streamlined: bad_alloc exceptions have been removed.

• The word class in templates has been replaced by the new keyword
typename. The keyword typename is intuitively more self-explanatory
and is not as overloaded as class.

• For the linked data structures where we had external “Node” classes, they
have become inner classes. Although inner classes add a small amount of
syntax, it gets away from the issues of forward declarations for mutually
referring classes. This represents better object-oriented design and we
avoid the use of declaring class friends.

• Copy constructors and overloaded assignment operators are now required


for every ADT implementation.

• The isFull operation has been removed from linked data structures where
it is not required for compatibility with the array-based version. We do
this because determining whether dynamic memory is exhausted is a
fruitless and inefficient exercise. In reality, C++ provides an exception
mechanism to deal with this issue.

• More sophisticated use of templates is presented. Template specialization


is introduced in the Expression Tree. Default template types and template
parameters are introduced in the Heap.

• Lab order has been changed to be compatible with the order in the largest
number of current textbooks. The singly-linked list was moved up to Lab
5 right after the two array-based lists; the expression tree is now before
the binary search tree; the string lab was moved to Lab 1; and the
BlogEntry ADT—the only new lab—is Lab 2.

Note: We still do not use STL in this book (except for one example in the
Performance Analysis lab). However, the STL implementation of a data structure
could be substituted for the student's implementation in necessary situations.

To the Student

Objectives

The courses that we enjoyed most when we were students were those that
emphasized design. In design-oriented courses, we used the concepts taught to
solve practical problems. The process of applying ideas made it easier to
understand them and their application in a real-world setting.
This emphasis on learning by doing is used throughout this book. In each
laboratory, you will explore a particular data structure by implementing it. As
you create an implementation, you will learn how the data structure works and
how it can be applied. The resulting implementation is a working piece of
software that you can later use in laboratories and programming projects.

Organization of the Laboratories

Each laboratory consists of three parts: Basic Implementation and Testing,


Programming Exercises, and Analysis Exercises. The Basic Implementation
section explains the specific Abstract Data Type (ADT), introduces the new C++
concepts, describes the ADT's properties, explains implementation details that
you need to know, and then guides you through testing your implementation. In
the three Programming Exercises, the first exercise is usually to apply the data
structure you created to the solution of a problem. The remaining two exercises
usually apply or extend the concepts introduced in the Basic Implementation.
The last part of each laboratory, the Analysis Exercise, is an assignment in which
you analyze a data structure in terms of its efficiency or use.
Your instructor will specify which exercises you need to complete for each
laboratory and when they are due. You are encouraged to use the cover sheet
provided with the online laboratory worksheets to keep track of the exercises
you have been assigned. Implementation testing is very important—probably
just as important a step as implementing the ADT—and should not be skipped.

Student Resources

The authors have compiled a set of worksheets, interactive tools to test and
debug your work, and “starter kits” containing data, partial solution shells, and
other supporting routines for each of your labs. These tools are available for
download at the Jones and Bartlett lab book website
http://www.jbpub.com/catalog/9780763755645.

To the Instructor

Objectives

When James Robergé was first given the opportunity to introduce


laboratories into his data structures course, he jumped at the chance. He saw
laboratories as a way of involving students as active, creative partners in the
learning process. By making the laboratories the focal point of the course, he
sought to immerse his students in the course material. The goal of each lab is
still to challenge students to exercise their creativity (in both programming and
analysis) while at the same time providing the structure, feedback, and support
that they need to meet the challenge. This manual is the product of years of
experimentation and refinement working toward this objective.

Organization of the Laboratories

In the initial development of these labs, an attempt was made to shoehorn the
creative process into a series of two-hour laboratories. The result was a pressure
cooker that challenged everyone, but helped no one. In experimenting with
solutions to this problem, James Robergé developed a laboratory framework that
retains the creative element but shifts the time-intensive aspects outside the
laboratory period. Within this structure, each laboratory includes three parts:
Basic Implementation and Testing, Programming Exercises, and Analysis
Exercises.
The Basic Implementation section explains the specific Abstract Data Type
(ADT), introduces the new C + + concepts, describes the ADT's properties,
explains implementation details that the student needs to know, and then guides
the student through testing his/her implementation. In the three Programming
Exercises, the first exercise is usually to apply the data structure to the solution
of a problem. The remaining two exercises usually apply or extend the concepts
introduced in the Basic Implementation. The last part of each laboratory, the
Analysis Exercise, is an assignment which analyzes a data structure in terms of
its efficiency or use.

Basic Implementation
The Basic Implementation exercise is intended as a homework assignment
that links the lecture with the laboratory period. Students explore and create on
their own and at their own pace. Their goal is to synthesize the information they
learn in lectures with material from their textbook to produce a working piece of
software, usually an implementation of an abstract data type (ADT). The
implementation assignment— including a review of the relevant lecture and
textbook materials—typically takes four to five hours to complete. We have tried
to include all necessary discussions of new C++ material, implementation
details, special compilation directions, and testing instructions. You should give
students specific instructions for compilation in your laboratory environment.
An interactive, command-driven test program is provided for each laboratory,
along with a text-based visualization routine that allows students to see changes
in the content and organization of a data structure. This part of the assignment
provides an opportunity for students to receive feedback on their basic
implementation and to resolve any difficulties they might have encountered. It
should take students approximately one hour to finish this exercise. Students are
often tempted to skimp on the testing, resulting in poorly implemented
submissions. Requiring students to complete and submit the test plans in the
online worksheets can significantly improve the quality of submissions.

Programming Exercises
This section takes place during the actual laboratory period (assuming you
are using a closed laboratory setting). Each lab contains three exercises, and each
exercise has a distinct role. In Exercise 1, students apply the software they
developed in the Basic Implementation to a real-world problem that has been
honed to its essentials to fit comfortably within the closed laboratory
environment. The last two exercises stress programming by extending the data
structure, and provide a capstone to the basic implementation. Exercise 1 can be
completed in approximately one and a half hours. Exercises 2 and 3 can take as
much as one hour each to complete, but students who did the initial work
thoroughly have a better understanding and can finish more quickly.
Most students will not be able to complete all these programming exercises
within a typical closed laboratory period. We have provided a range of exercises
so that you can select those that best suit your laboratory environment and your
students' needs.

Analysis Exercises
The last phase of each laboratory is a set of two homework assignments in
which students analyze the efficiency or utility of a given data structure. Each
Analysis Exercise should take roughly thirty minutes to complete. Assuming a
closed laboratory structure, one or both could be done following the laboratory
period.

Using the Three-Part Organization in Your Laboratory


Environment

The term laboratory is used by computer science instructors to denote a


broad range of environments. One group of students in a data structures course,
for example, may attend a closed two-hour laboratory; at the same time, another
group of students may take the class in a televised format and “attend” an open
laboratory. In developing this manual, we have preserved the first edition's
efforts to create a laboratory format suitable for a variety of open and closed
laboratory settings. How you use the organization depends on your laboratory
environment.

Two-Hour Closed Laboratory

Basic Implementation
We expect the students attending a two-hour closed laboratory to make a
good-faith effort to complete the basic implementation exercise before coming to
the lab. Their work need not be perfect, but their effort must be real (roughly
80% correct). We ask our students to complete the test plans and to begin testing
and debugging their implementation work prior to coming to lab (as part of the
80% correct guideline).

Programming Exercises
We use the first hour of the laboratory period to resolve any problems the
students might have experienced in completing the Basic Implementation and
Testing. Our intention is to give constructive feedback so that students leave the
lab with a working implementation—a significant accomplishment on their part.
During the second hour, we have students complete one of the programming
exercises in order to reinforce the concepts learned in the basic implementation.
You can choose the exercise by section or by student, or you can let the students
decide which one to complete.
Students leave the lab having received feedback on their basic implementation
and additional programming exercise work. You need not rigidly enforce the
hourly divisions; a mix of activities keeps everyone interested and motivated.

Analysis Exercises
After the lab, the students complete one (or both) of the analysis exercises
and turn it in during their next lab period.

One-Hour Closed Laboratory

Basic Implementation
If we have only one hour for the closed laboratory, we ask students to
complete all of the Basic Implementation and Testing before they come to the
lab. This work is turned in at the start of the period.

Programming Exercises
During the laboratory period, the students complete one of the additional
programming exercises.
Analysis Exercises
Again, the students complete one or both of the analysis exercises and
submit it during their next lab period.

Open Laboratory

In an open laboratory setting, we have the students complete the Basic


Implementation and Testing exercises, one of the additional programming
exercises, and one or both of the analysis exercises. You can stagger the
submission of these exercises throughout the week or have students turn in the
entire laboratory as a unit.

Student Preparation

This manual assumes that students have a background in either Java or C++.
The first laboratory introduces classes and the use of classes to implement a
simple ADT. Succeeding laboratories introduce more complex C++ language
features (dynamic memory allocation, templates, inheritance, and so forth) in the
context of data structures that use these features.

Order of Topics

All instructors cover the course material in the order that they believe best
suits their students' needs. To give instructors flexibility in the order of
presentation, we have made the individual laboratories as independent of one
another as possible. At a minimum, we recommend beginning with the following
sequence of laboratories:

Laboratory 1 (Text ADT)


Introduces the implementation of an ADT using C++ classes and a
number of foundational features, including constructors, destructors, basic
dynamic memory allocation, and operator overloading. Depending on the
student background, you may choose to implement this over the course of
two weeks.

Laboratory 2 (BlogEntry ADT)


Continues the overview of significant C++ features. Introduces member
initialization, exceptions, static methods, class composition, and extending
iostream functionality.

Laboratory 3 (Array Implementation of the List ADT)


Introduces templates and prepares students for inheritance.

Laboratory 5 (Singly-Linked Implementation of the List ADT)


Introduces linked lists and inner classes.

We have placed the performance evaluation laboratory at the end of the book
(Laboratory 13), because in our experience, we have found that everyone covers
this topic at a different time. Rather than bury it in the middle of the manual, we
have placed it at the end so that you can include it where it best serves you and
your students' needs, be that early in the semester, in the middle, or toward the
end.

ADT Implementation

The laboratories are designed to complement a variety of approaches to


implementing each ADT. All ADT definitions stress the use of data abstraction
and generic data elements. As a result, you can adapt them with minimal effort
to suit different implementation strategies.
For each ADT, class declarations that frame an implementation of the ADT
are given as part of the corresponding basic implementation exercise. This
declaration framework is also used in the visualization function that
accompanies the laboratory. Should you elect to adopt a somewhat different
implementation strategy, you need only make minor changes to the data
members in the class declarations and corresponding modifications to the
visualization routine. You do not need to change anything else in either the
supplied software or the laboratory text itself.

Differences Between the Manual and Your Text

We have found that variations in style between the approaches used in the
textbook and the laboratory manual discourage students from simply copying
material from the textbook. Having to make changes, however slight, encourages
them to examine in more detail how a given implementation works.
Combining the Laboratories with Programming Projects

One of our goals in designing these laboratories was to enable students to


produce the laboratory code that they can use again as part of larger, more
applications-oriented programming projects. The ADTs the students develop in
the basic implementation exercises provide a solid foundation for such projects.
Reusing the material that they created in the laboratory frees students to focus on
the application they are developing. More important, they see in concrete terms
—their time and effort—the value of such essential software engineering
concepts as code reuse, data abstraction, and objectoriented programming.
The first extra programming exercise in each lab is usually an application
problem based on the material covered in the basic implementation for that
laboratory. These exercises provide an excellent starting point for programming
projects. Free-form projects are also possible.

Student Resources

Challenging students is easy; helping them to meet a challenge is not. The


student resources found at the Jones and Bartlett website for the book include a
set of software tools that assist students in developing ADT implementations.
The tools provide students with the means for testing an ADT implementation
using simple keyboard commands and for visualizing the resulting data structure
using ASCII text on a standard text display. Additional files containing data,
partial solution shells, other supporting routines, and online worksheets are also
available for download at http://www.jbpub.com/catalog/9780763755645.

Instructor's Resources

An instructor's solutions kit is available for download at the publisher's


website. Solutions to all of the basic implementation and extra programming
exercises are included. To register, please visit:
http://www.jbpub.com/catalog/9780763755645.
We have been using online unit testing technology to automate the
submission, assessment, and feedback generation for student labs. If you are
interested, please contact Stefan Brandle (sbrandle@css.taylor.edu) for details.
In addition, if you have questions, discover errors, etc., please feel free to send
an email.

Acknowledgments
Writing this type of lab manual is an “iceberg” project—much of the work
goes into the implementation of a programming infrastructure that is only
somewhat visible on the printed page. We owe many thanks to James Robergé
for the vision that inspired the lab. We are also indebted to all the reviewers,
editors, and publication teams who helped with make the first, second, and third
editions reality. In particular, we wish to thank the current team at Jones and
Bartlett for their patience and work: Tim Anderson, Amy Rose, and Melissa
Elmore.
Additionally, our family members are always owed a big thank you for
supporting us kindly throughout the process.
laboratory 1
Text ADT

Objectives
In this laboratory, you
are introduced to the concept of an Abstract Data Type (ADT).
implement an ADT using a C++ class.
use the C++ operators new and delete to dynamically allocate and
deallocate memory.
learn the C++ mechanisms for implementing classes correctly and
efficiently.
create a program that performs lexical analysis using your new Text data
type.
examine the problems with the standard C string representation.

ADT Overview

The purpose of this laboratory is for you to explore how you can use C++
classes to implement an abstract data type (ADT). In this laboratory, you will
implement your own string type, the Text class.
When computers were first introduced, they were popularly characterized as
giant calculating machines. This characterization ignores the fact that computers
are equally adept at manipulating other forms of information, including
sequences of symbols called strings. Text is a type of string that is composed of
human-readable characters. In this lab we will be working with text.
C++ provides a set of predefined, or “built-in,” data types (e.g., int, char, and
float). Each of these predefined types has a set of operations associated with it.
You use these operations to manipulate variables of a given type. For example,
type int supports the basic arithmetic and relational operators, as well as a
number of numerical functions (abs and div, etc.). These predefined data types
provide a foundation on which you construct more sophisticated data types,
types that are collections of related data items, rather than individual data items.
Each of the user defined data types in this book will be discussed in two steps.
First, we describe them as ADTs (abstract data types). An ADT is the description
of a set of data items and of the operations that can be performed on that data.
The “abstract” part means that the data type is described independent of any
implementation details. Second, we discuss implementation details for turning
the ADT description into a usable language-specific data structure. You will
implement each ADT by writing one or more C++ classes that make it possible
to instantiate actual C++ objects—variables of the user-defined data type—that
meet the ADT specifications.
When specifying an ADT, you begin by describing the data items that are in
the ADT. You describe how the ADT data items are organized to form the ADT's
structure. In the case of the Text ADT, the data items are the letters associated
with a text string and the structure is linear: the entries are arranged in the same
order as they would appear in written form.
Having specified the data items and the structure of the ADT, you then define
how the ADT can be used by specifying the operations that are associated with
the ADT. For each operation, you specify what conditions must be true before
the operation can be applied (its preconditions, or requirements) as well as what
conditions will be true after the operation has completed (its postconditions, or
results). The following Text ADT specification includes operations to create and
initialize a Text object, assign text to it, compare it to other Text objects, and
retrieve the letters at specific positions within the Text object.

C++ Concepts Overview

Many important C++ concepts are introduced in this lab. In this section, we
briefly describe each.
Constructors: This is a member function that is automatically run to
initialize new objects when they are created. If each C++ class has an
appropriate constructor, it will guarantee that all objects of that class are
initialized before the programmer can do anything else with the object, thus
ensuring that the programmer will always be working with properly initialized
data. Like overloaded functions, there can be multiple constructors provided that
each has a unique combination of parameter types (the function's signature). To
be safe, all C++ classes should have one or more constructors.
Destructor: This is a member function that automatically runs when an
object is destroyed. The destructor is responsible for doing any object “clean up”
that needs to happen before the object is destroyed. The destructor's most
important responsibility in C++ is to ensure that any memory the object
borrowed from the memory manager gets returned correctly. Object destruction
happens implicitly when the object goes out of scope, or as a result of the
programmer explicitly deleting an object.
Dynamic memory allocation: It is quite common to need a block of memory
of a specific size—typically an array—at runtime. In C++, the code requests this
memory from the memory management routines by using the new keyword.
When the memory block is no longer needed, it is returned to the dynamic
memory pool by using the delete keyword. Forgetting to return dynamically
allocated memory leads to a serious problem called a memory leak. Any class
that performs dynamic memory allocation needs a destructor to help return the
memory when the object gets destroyed.
Class protection and access mechanisms: Data and member functions in
C++ classes can be protected from access outside the class by declaring them in
one of three sections of the class: public, private, and protected. Anything
declared in the public section is freely accessible from anywhere outside the
class. The object-oriented programming (OOP) philosophy is that data and
member functions should be public only on a “need to be public” basis, so they
should only be placed in the public section if they really need to be there. Data is
almost never declared as public. Items in the private section are accessible only
to member functions within that class. Member functions and data in the
protected section are treated as private, except that classes that are derived from
the given class (through inheritance) are given access to anything in the
protected section. C++ also allows the use of friend to let a class give a function
or another class access to its contents. The use of friend will be discussed later
when it is needed.
Operator overloading: C++ knows what to do when it sees operators used
with predefined data types, but it generally does not know what to do with the
user-defined data types and doesn't even try. And when it does try, the results are
often not what the programmer intended. To solve the behavior problem, C++
allows a class to redefine the meaning of an operator used in the context of an
object of that class. Examples include the ‘<’, ‘=’, ‘==’ ‘[]‘, and ‘+' operators.
Const protection: In C++, there are sometimes objects that may not be
changed in a specific context. In those cases, the compiler needs to know
whether calling a specific member function would illegally change the object. A
member function can be declared to be a const function, meaning that running it
does not cause changes to any of the object's data values. Additionally, a
function parameter can be declared const, meaning that the function may not
modify the parameter.

Text ADT Specification

Data items

A set of characters, excluding the null character.

Structure

The characters in a Text object are in sequential (or linear) order—that is, the
characters follow one after the other from the beginning of a string to its end.

Operations

Requirements:
None

Results:
Conversion constructor and default constructor. Creates a Text object containing
the character sequence in the array pointed to by charSeq. This constructor
assumes that charSeq is a valid C-string terminated by the null character (‘\0’)
and allocates enough memory for the characters in the array plus any delimiter
that may be required by the implementation of the Text ADT.

Requirements:
None

Results:
Copy constructor. Initializes the object to be an equivalent copy of other. This
constructor is invoked automatically whenever a Text object is passed to a
function using call by value, a function returns a Text object, or a Text object is
initialized using another Text object.

Requirements:
None

Results:
Assigns the value of other to this Text object.

Requirements:
None

Results:
Destructor. Deallocates (frees) the memory used for the implementation of the
Text ADT.

Requirements:
None

Results:
Returns the number of characters in the Text object (excluding the delimiter).

Requirements:
None
Results:
Returns the nth character in the Text object—where the characters are numbered
beginning with zero. If the object does not have an nth character, then it returns
the null character.
Requirements:
None

Results:
Clears the Text object, thereby making it an empty Text object.

Requirements:
None

Results:
Outputs the characters in the Text object, as well as the delimiter. Note that this
operation is intended for testing/debugging purposes only.

Implementation Notes

C-strings: C++ supports the manipulation of character data through the


predefined data type char and the associated operations for the input, output,
assignment, and comparison of characters. Most applications of character data
require character sequences—or strings—rather than individual characters. A
string can be represented in C++ using a one-dimensional array of characters. By
convention, a string begins in array data item zero and is terminated by the null
character, ‘\0’. (That is how C and early C++ represented strings. Although C++
now has a standard string class, many current programming APIs—Application
Programming Interfaces—require a knowledge of the C-string representation.)
Representing a string as an array of characters terminated by a null suffers
from several defects, including the following:

• The subscript operator ([]) does not check that the subscript lies within the
boundaries of the string—or even within the boundaries of the array
holding the string, for that matter.

• Strings are compared using functions that have far different calling
conventions than the familiar relational operators (==, <, >, and so forth).
• The assignment operator (=) simply copies a pointer, not the character
data it points to. The code fragment shown here, for example, makes str2
point to the array already pointed to by str1. It does not create a new
array containing the string “data”. This results in changes to str2
affecting str1 since they share the array, and vice versa.

Either the length of a string must be declared at compile-time or a program


must explicitly allocate and deallocate the memory used to store a string.
Declaring the length of a string at compile-time is often impossible, or at least
inefficient. Allocating and deallocating the memory used by a string dynamically
(that is, at run-time) allows the string length to be set (or changed) as a program
executes. Unfortunately, it is very easy for a programmer to forget to include
code to deallocate memory once a string is no longer needed. Memory lost in
this way—called a memory leak—accumulates over time, gradually crippling or
even crashing a program. This will eventually require the program or computer
system to be restarted.
In this laboratory, you develop a Text ADT that addresses these problems. The
Text ADT specification that follows includes a diverse set of operations for
manipulating strings.
The first decision you must make when implementing the Text ADT is how to
store the characters in a string. Earlier, you saw that original C++ represented a
string as a null-terminated sequence of characters in a one-dimensional buffer.
Adopting this representation scheme allows you to reuse existing C ++ functions
in your implementation of the Text ADT. This code reuse, in turn, greatly
simplifies the implementation process.
Your Text ADT will be more flexible if you dynamically allocate the memory
used by the string buffer. The initial memory allocation for a buffer is done by a
constructor. One of the constructors is invoked whenever a text declaration is
encountered during the execution of a program. Which one is invoked depends
on whether the declaration has as its argument an integer or a string literal. Once
called, the constructor allocates a string buffer using C++'s new[] operator. The
constructor that follows, for example, allocates a string buffer of bufferSize
characters and assigns the address of the string buffer to the pointer buffer,
where buffer is of type char*.
Whenever you allocate memory, you must ensure that it is deallocated when
it is no longer needed. The class destructor is used to deallocate a string buffer.
This function is invoked whenever a string variable goes out of scope—that is,
whenever the function containing the corresponding variable declaration
terminates. The fact that the call to the destructor is made automatically
eliminates the possibility of you forgetting to deallocate the buffer. The
following destructor frees the memory used by the string buffer allocated
previously.

Constructors and destructors are not the only operations that allocate and
deallocate memory. The assignment operation may also need to perform memory
allocation/ deallocation in order to extend the length of a string buffer to
accommodate additional characters.
Strings can be of various lengths and the length of a given string can change
as a result of an assignment. Your string representation should account for these
variations in length by storing the length of the string (bufferSize) along with a
pointer to the buffer containing the characters in the string (buffer). The
resulting string representation is described by the following declarations.

Defaulting parameters: C++ allows the programmer to set up default values


for parameters to a function. A default parameter is used in the Text constructor
function. Given the function prototype

the constructor function should be called with some sort of C-string as a


Exploring the Variety of Random
Documents with Different Content
soon became evident to Bainbridge that Captain Lambert’s guns
carried better than his own, so began luffing up repeatedly in order
to shorten the distance for an effective broadside. He was sure of his
marksmanship if once his men got the range, for the same gun-
captains were with him that had helped Hull to her great victory over
the “Guerriere.” It was difficult to draw up, as the Englishman was
forging ahead with the evident desire to sail close to the wind and
keep the weather-gage at all hazards. The “Constitution” could only
luff up at opportune moments, for Lambert’s position was one which
would enable him to rake the “Constitution” from stem to stern if he
luffed when the broadside was ready. But he edged up cautiously,
and soon the vessels were but musket-shot apart. A continuous fire
now began, and the wind being light, both vessels were soon so
shrouded in smoke that only at intervals could the gunners make out
their adversaries. Along they sailed, side by side, giving and
receiving tremendous volleys. About this time a solid shot went
crashing along the quarter-deck of the “Constitution” and, striking
her wheel, smashed it to pieces. The gear had been rove below,
however, and the ship throughout the remainder of the battle was
steered by means of tackles on the berth-deck. The captain’s orders
were shouted down through the after-hatch and repeated by a line
of midshipmen to the men at the tackles.
Bainbridge, in full uniform, stood by the weather-rigging at the
time the disabling shot came aboard, and a small copper bolt drove
through the upper part of his leg, inflicting a bad wound. But fearing
that if he left the deck his men might lose some of the ardor with
which they were fighting, he would not go below though frequently
urged so to do. Instead of this he bound it up with his handkerchief,
and remained at his post, his epaulettes a fair mark for the
sharpshooters in the tops of the enemy. His men down in the waist
of the “Constitution” looked now and again at the imposing figure by
the mizzen-mast, and bent to their work with a will, firing as rapidly
as their guns could be loaded. The distance between the ships was
now so short that all the smaller guns and carronades could be
used, and a rapid and well-directed fire was kept up both upon the
hull and the spars of their adversary.
The “Java,” by her superior sailing qualities, was enabled to
reach well forward on the “Constitution’s” bow when she eased off
her sheets to round down across the bows of the American and
rake. But Bainbridge, in spite of the disadvantage of wrecked
steering-gear, was too quick for her. He put his helm up, and wore
around in the smoke, thus keeping his broadside presented. The
Englishman at last succeeded in getting under the “Constitution’s”
stern and pouring in a broadside at close range. But, fortunately,
comparatively little damage was done. The superiority of the
gunnery of the Americans, save for a few of the Englishman’s well-
directed shots, had been from the first far superior to that of the
Englishmen. The fire of the “Java” was far less rapid and less careful
than that of the “Constitution.” Had the gunnery been equal, the
story of the fight would have had a different ending.
But the Americans labored under a great disadvantage, and
Captain Bainbridge, determined to close with the enemy at all
hazards, put his helm down and headed directly for the enemy, thus
exposing himself to a fore-and-aft fire, which might have been
deadly. But for some reason the Englishman failed to avail himself of
this opportunity, only one 9-pounder being discharged. When near
enough, the “Constitution” rounded to alongside and delivered her
entire starboard broadside, which crashed through the timbers of the
“Java” and sent the splinters flying along the entire length of her
bulwarks. The shrieks of the injured could be plainly heard in the
lulls in the firing, and soon the bowsprit and jib-boom of the enemy
were hanging down forward, where they lay, with the gear of the
head-sails and booms in a terrible tangle. With this misfortune the
“Java” lost her superiority in sailing, and this was the turn in the
action. Quickly availing himself of this advantage, Bainbridge again
wore in the smoke before Captain Lambert could discover his
intentions, and, getting under the “Java’s” stern, poured in a rapid
broadside, which swept the decks from one end to the other, killing
and wounding a score of men. Then sailing around, he reloaded, and
fired another broadside from a diagonal position, which carried away
the “Java’s” foremast and otherwise wrecked her.
Captain Lambert, now finding his situation becoming desperate,
determined to close with the “Constitution” and board her. He tried
to bear down on her, but the loss of his head-yards and the wreck
on his forecastle made his vessel unwieldy, and only the stump of his
bowsprit fouled the mizzen-chains of the American vessel. The
American topmen and marines during this time were pouring a
terrific fire of musketry into the mass of men who had gathered
forward on the English vessel. An American marine, noting the
epaulettes of Captain Lambert, took deliberate aim, and shot him
through the breast. Lambert fell to the deck, and Lieutenant Chads
assumed the command. The Englishmen, disheartened by the loss of
their captain, still fought pluckily, though the wreck of the gear
forward and the loss of their maintop-mast seriously impeded the
handling of the guns. At each discharge their sails and gear caught
fire, and at one time the “Java’s” engaged broadside seemed a sheet
of flame. At about four o’clock her mizzen-mast, the last remaining
spar aloft, came down, and she swung on the waves entirely
dismasted. It seemed impossible to continue the action, as but half a
dozen guns could be brought to bear.
The “Constitution,” finding the enemy almost silenced and
practically at her mercy, drew off to repair damages and re-reeve her
gear. Bainbridge had great confidence in the look of the
“Constitution,” as, to all outward appearances unharmed, she bore
down again and placed herself in a position to send in another
broadside. His surmise was correct, for the one flag which had
remained aloft was hauled down before the firing could be resumed.
Lieutenant George Porter, of the “Constitution,” was immediately
sent aboard the Englishman. As he reached the deck he found the
conditions there even worse than had been imagined by those
aboard the “Constitution.” Many of the broadside guns were
overturned, and, though the wreck had been partially cleared away,
the tangle of rigging was still such that the remaining guns were
practically useless. The dead and wounded literally covered the
decks, and as the lieutenant went aboard the dead were being
dropped overboard. The loss of her masts made her roll heavily, and
occasionally her broadside guns went under. Lambert was mortally
wounded. Lieutenant Chads, too, was badly hurt. When he had
assumed command, in spite of the fact that he knew his battle was
hopeless, he had tried to refit to meet the American when she came
down for the second time. He only struck his colors when he knew
that further resistance meant murder for his own brave men. The
“Java” was a mere hulk, and the hulk was a sieve.
Comparison of the injuries of the “Java” and “Constitution” is
interesting. With the exception of her maintop-sail-yard, the
“Constitution” came out of the fight with every yard crossed and
every spar in position. The injuries to her hull were trifling. The
“Java” had every stick, one after another, shot out of her until
nothing was left but a few stumps. It might have been possible to
have taken her into Bahia, but Bainbridge thought himself too far
away from home; and so, after the prisoners and wounded had been
removed to the “Constitution,” a fuse was laid, and the American got
under weigh. Not long after a great volume of smoke went up into
the air, and a terrific explosion was heard as the last of the “Java”
sunk beneath the Southern Ocean.
When the “Constitution” arrived at Bahia, Captain Lambert was
carried up on the quarter-deck, and lay near where Bainbridge, still
suffering acutely from his wounds, had been brought. Bainbridge
was supported by two of his officers as he came over to Lambert’s
cot, for he was very weak from loss of blood. He carried in his hand
the sword which the dying Englishman had been obliged to
surrender to him. Bainbridge put it down beside him on his bed,
saying,—
“The sword of so brave a man should never be taken from him.”
The two noble enemies grasped hands, and tears shone in the
eyes of both. A few days afterwards the Englishman was put on
shore, where more comfortable quarters were provided for him, but
he failed rapidly, and died five days after.
The news of the capture of the “Java” created consternation in
England. The loss of the “Guerriere” and the “Macedonian” were
thought to have been ill-luck. But they now discovered an inkling of
what they rightly learned before the war was over,—that the navy of
the United States, small as it appeared, was a force which, man for
man and gun for gun, could whip anything afloat.
When Bainbridge arrived in Boston he and his officers were met
by a large delegation of citizens, and many festivities and dinners
were held and given in their honor. The old “Constitution,” rightly
deserving the attention of the government, was put in dry-dock to
be thoroughly overhauled. Of the five hundred merchantmen
captured by Americans, she had taken more than her share, and of
the three frigates captured she had taken two.
THE LAST OF THE “ESSEX”

W
hen Captain David Porter in the “Essex” failed to meet
Captain Bainbridge in the “Constitution” off the Brazilian
coast, and learned that the latter had captured the “Java”
and returned to the United States, he was free to make his own
plans and choose his own cruising-ground.
He captured an English vessel or so, but his ambition was to
make a voyage which would result in the capture of as many vessels
as could be manned from the “Essex.” He thought the matter over at
length and then formulated a plan which few other men would have
thought of. No large war-vessel of the American government had
been in the South Pacific for some years, and now the English
whalers and merchantmen pursued their trade unmolested, save by
a few privateers which sailed haphazard in the waters along the
coast. David Porter decided to round the Horn, thus cutting himself
off from his nearest base of supplies, and live the best way he might
off vessels captured from the enemy.
He knew that he could not hope for a hospitable reception at
any port he visited, but if he could keep his magazine and store-
rooms supplied, determined to capture or destroy every vessel flying
the British flag in those waters.
He started on his long voyage at the end of January, 1813,
during the Southern summer season, when the gales and hurricanes
in that region are at their fiercest. He had not been at sea very long
before the scurvy broke out on the ship, and it was only by the most
rigorous discipline and cleanliness that the disease was kept under
control. By the middle of February the “Essex” reached the Cape,
and, the weather having been moderately free from squalls, they
were congratulating themselves on avoiding the usual dangers of
those waters when a storm came up which in a short time began to
blow with hurricane force. Gale succeeded gale, followed by intervals
of calm, but nothing terrifying occurred until towards the end of
February, when a storm which exceeded all the others in its
fierceness began to blow. They were near a barren country, and,
even should they reach land, there was no possible chance of
escaping the slow torture of death from hunger and thirst. Great
gray waves, measuring hundreds of feet from crest to crest, swept
them resistlessly on towards the menacing shore, which could be
seen dimly through the driving spray frowning to leeward. Many of
the waves broke clear over the little frigate, knocking in her ports,
opening her timbers, battering her boats to pieces as they swung on
the davits, and loosening her bowsprit and other spars so that they
threatened at each movement to go by the board. The crew,
weakened and disheartened by disease and the excess of labor, lost
heart and considered the “Essex” a doomed ship. David Glascoe
Farragut, then a midshipman aboard of her, afterwards wrote that
never before had he seen good seamen so paralyzed by fear at the
mere terrors of the sea. On the third day an enormous wave struck
her fairly on the weather-bow and broadside, and she went over on
her beam ends, burying her lee-bulwark in the foam. It looked for a
moment as if she would never right herself. The ports on the gun-
deck were all stove in and she seemed to be filling with water. The
head-rails were swept away, and one of the cutters was lifted bodily
from the davits and smashed against the wheel. The fellows there
stood bravely at their posts, though thoroughly terrified at the
position of the ship. The water poured down below, and the men on
the gun-deck thought she was already plunging to the bottom. The
grizzly boatswain, crazy with fear, cried out in his terror,—
“The ship’s broadside is stove in! We are sinking!”
That was the greatest of their dangers, though, and better days
were in store for them. Early in March the “Essex” succeeded in
reaching Mocha Island, and the men, starved on half and quarter
rations, were sent ashore to hunt wild hogs and horses. These were
shot in numbers and salted down for food. The crew soon regained
their health and spirits, and Porter sailed away for Valparaiso,
putting in there to refit his damaged rigging and spars.
And now began a cruise which is numbered among the most
successful in the country’s history. Porter had been at sea but a few
days when he overhauled a Peruvian privateer, the “Nereyda.” To his
surprise, twenty-four American sailors were found prisoners aboard
of her. When asked to explain, the Peruvian captain replied that as
his country was an ally of Great Britain, and that as war was soon to
be declared between Spain and America, he thought he would
anticipate matters and be sure of his prizes. Porter, in forcible
English, explained the Peruvian’s mistake, and, to make the matter
more clear, threw all his guns and ammunition overboard, so that he
might repent of his folly in a more diplomatic condition.
The Peruvian captain begrudgingly gave Porter a list of all the
English vessels in those waters. The first one captured was the
whaler “Barclay.” On the 29th of April the “Essex” took the
“Montezuma,” with a cargo of fourteen hundred barrels of whale-oil.
Later in the same day the “Georgiana” and the “Policy” were
overhauled. These prizes, with their cargoes, in England were worth
half a million dollars; but, better than money, they were plentifully
supplied with ropes, spars, cordage, stores, and ammunition, of
which Porter still stood badly in need.
Finding that the “Georgiana” was a fast sailer and pierced for
eighteen guns, Porter decided to make use of her as a cruiser, and,
fitting her up, placed Lieutenant Downes in command of her, with
forty men for a crew. Then the “Essex” took the “Atlantic” and the
“Greenwich.” With this very respectable squadron Porter sailed for
the mainland, Lieutenant Downes in the “Georgiana” meanwhile
capturing without great difficulty the “Catharine” and the “Rose.” A
third vessel, the “Hector,” fought viciously, but was eventually
secured after a stiff little battle.
Young Farragut had been made the prize-master of the
“Barclay.” He was only twelve years old, but Captain Porter, who was
very fond of him, was confident of his ability to bring the ship into
port. The English captain had been persuaded to act as navigator;
but once out of sight of the squadron he refused to sail for
Valparaiso. He afterwards said it was merely to frighten the boy. But
the boy did not frighten at all. Instead he called one of his best
seamen to him and ordered sail made. Then he told the captain that
if he did not go below and stay there he would have him thrown
overboard. The Englishman retreated below precipitately, and
Farragut brought the ship safely in, a first proof of the courage and
skill he was to show in after-life. Few boys of twelve would have
done it even in those days when midshipmen soon became men
regardless of age.
The “Atlantic,” being reckoned the fastest vessel of her kind
afloat in those waters, was now given to Downes, who had been
promoted to master-commandant, and renamed the “Essex Junior.”
She was given twenty guns and sixty men, and soon proved her
worth. All of this time Porter had been self-supporting. Neither he
nor his squadron had cost his government a penny in money, and
the prizes he captured, including the “Charlton,” “Seringapatam,”
“New Zealand,” and “Sir Andrew Hammond,” could not be reckoned
much short of a million and a half of dollars, a tremendous sum in
those days, when the pay of a captain of a naval vessel was only
twelve hundred dollars,—less than the pay of a boatswain to-day.
But Porter grew tired of his easy victories over merchantmen
and privateers. He had succeeded in frightening the ships of the
British entirely from the ocean. His one ship, a small frigate, had
complete control in the South Pacific, and the Admiralty wondered at
the skill and ingenuity of a man who could manage his fleets so
adroitly. They determined to capture him; and two smart ships, the
“Phœbe” and the “Cherub,” were sent out for this purpose. Porter
heard of their coming, and was willing enough to meet them if it
were possible. He went to Nukahiva, in the Marquesas Islands, to
put the “Essex” in thorough repair and give his men a rest. He
remained there two months, sailing near the end of the year 1813
for Valparaiso, with the hope of their meeting the English cruisers.
The “Essex” had been there but a month when the “Essex
Junior,” which was cruising in the offing in anticipation of the arrival
of the British ships, signalled, “Two enemy’s ships in sight.” Half the
crew of the “Essex” were ashore enjoying sailor-men’s liberty. Even if
they all got aboard, it was fair to assume that they would be in no
condition to fight should the Englishmen choose to violate the
neutrality of the port by firing on them. Porter immediately fired a
gun and hoisted the recall signal for all boats and men to return.
The English captain, Hillyar, ran the “Phœbe” on the wind straight for
the “Essex,” the “Cherub” following closely. But when they reached
the anchorage, the “Essex” was ready for action and the crew were
at their stations. The “Phœbe” went around under the quarter of the
“Essex,” luffing up scarcely fifteen feet away. It was an exciting
moment. Hillyar could see the men at their guns, and his ardor was
perceptibly diminished. Had he given the order to fire then, he would
have been raked fore and aft, and the tale of this last fight of the
“Essex” might have had a different ending.
As it was, he jumped upon the nettings, and said, with
distinguished politeness,—
“Captain Hillyar’s compliments to Captain Porter, and hopes he is
well.”
Porter was well, but he was in no humor to bandy compliments.
“Very well, I thank you,” he replied; “but I hope you will not
come too near, for fear some accident might take place which would
be disagreeable to you.” And at a wave of his hand the kedge-
anchors and grappling-irons were swung up to the yard-arms, ready
to be dropped on the decks of the enemy. The men swarmed along
the nettings, ready to jump aboard the Englishman as soon as she
was close enough.
But Hillyar, not liking the looks of things, changed his tone
considerably. He backed his yards hurriedly, and said in an excited
manner,—
“I had no intention of getting aboard of you. I assure you that if
I fall aboard it will be entirely accidental.”
“Well,” said Porter, “you have no business where you are. If you
touch a rope-yarn of this ship I shall board instantly.”
Porter then hailed Downes on the “Essex Junior” and told him to
be prepared to repel the enemy. The vessels were in a position to be
almost at the mercy of the Americans. When the “Phœbe” ranged
alongside, the crews could see each other through the ports, and
laughed and made grimaces at one another. One young fellow in the
“Essex,” who had come aboard drunk, stood at one of the guns,
match in hand. He saw one of the English jackies grinning at him.
He was primed for a fight, and yelled across,—
“I’ll stop your making faces, my fine fellow.” He leaned forward
to apply the match to the vent, and was only saved from firing it in
time by Lieutenant McKnight of the gun-division, who knocked him
sprawling. Had that gun been fired, the “Phœbe” would have been
taken.
There seems no doubt of Captain Hillyar’s previous intention to
try to take the “Essex” as she lay, regardless of the neutrality.
Captain Porter would have been justified if he had fired at that time.
But the Englishmen were willing to bide their time. Two more
British ships were expected, and they felt sure of their prey.
A strange state of affairs now ensued. The officers meeting on
shore exchanged the proper courtesies, and strict orders were issued
to the men, who for a wonder were restrained from fighting. Porter
flew from his foremast a great white burgee, bearing the legend,
“Free Trade and Sailors’ Rights.” Captain Hillyar soon hoisted one in
reply, “God and Country: British Sailors’ Best Rights. Traitors Offend
Both.” Porter then had another painted, and sent it to the mizzen,
which read, “God, Our Country, and Liberty. Tyrants Offend Them.”
These amenities had the effect of making the crew eager for a
speedy settlement of the question. Once Captain Hillyar fired a gun
in challenge; but upon Porter’s accepting it, the Englishman sailed
down to his consort the “Cherub,” and Porter returned. The
Englishman, in spite of his challenge, was not willing to fight a single
battle.
Finally, Captain Porter, learning of the expected early arrival of
the “Tagus,” 38, the “Raccoon,” and two other ships, determined to
put to sea and there fight it out with the two frigates as best he
might. The next day, the 28th of March, 1814, a squall came up, and
the “Essex” lost one of her anchors and dragged the other out to
sea. Not a moment was to be lost in getting sail on the ship, for he
saw a chance to sail between the southwest point of the harbor and
the enemy. Under close-reefed topsails Porter made a course which
seemed likely to carry him just where he wanted to go, when a
heavy squall struck the ship, carrying away the maintop-mast and
throwing the men who were aloft on the top-gallant-yard into the
sea.
This great misfortune at a time when there was at least a
fighting chance of getting away put a different aspect upon the
chances of the “Essex.” Both English vessels immediately gave
chase, and Porter, failing to make his anchorage, ran for shore, to
anchor there and fight it out to the last drop of blood. The “Phœbe”
and the “Cherub,” bedecked with flags, came booming down to
where Porter awaited them, flying flags from the stumps of his
maintop-mast and at almost every point where he could run a
halyard.
At about four o’clock the “Phœbe” selected a position under the
stern of the “Essex,” and opened fire at long range. The “Cherub”
stood off her bow. The fire of the “Phœbe” was terribly destructive,
and few guns from the “Essex” could be brought to bear upon her.
The “Cherub” fared differently; and, finding her position too hot,
sailed around and took up a position by her consort, where a
tremendous fire was poured in. Captain Porter, with great difficulty,
had three of his long 12-pounders hauled into his after-cabin, and at
last succeeded in opening such a fierce and well-aimed fire that the
enemy wore about and increased the distance between them. The
“Phœbe” had three holes in her water-line, had lost the use of her
mainsail and jib, and had her fore-main- and mizzen-stays shot
away. Her bowsprit was badly wounded, and she had other injuries
below.
But the “Essex” was fighting against terrible odds. The springs
on her cables were again and again shot away and the crew were
being killed and wounded in great numbers. When the ships of the
enemy returned and opened a galling fire from such a position that
it could not be returned by the “Essex,” Porter determined to assume
the aggressive. But when he attempted to make sail on his ship, he
found that most of the running-gear had been cut away, only his
flying-jib could be spread to the winds. But, nothing daunted, he cut
his cable, and, spreading his tattered canvases the best way he
could, made down for the “Cherub” until within range of the
cannonades, where he gave the Englishman such a drubbing that he
took to his heels and got out of range altogether. The “Phœbe”
managed to keep her distance, and with her long guns kept sending
in broadside after broadside, which swept the decks of the doomed
“Essex” and mowed her men down like chaff. Captain Hillyar was
taking no chances.
The slaughter on the “Essex” was horrible. One gun was
manned by three crews, fifteen men being killed at it. Men were
dying like sheep; but those who remained at the guns, and even the
wounded, had no thought of surrender. A sailor named Bissley, a
young Scotchman by birth, lost his leg. He lifted himself, and said to
some of his shipmates,—
“I hope I have proved myself worthy of the country of my
adoption. I am no longer of any use to you or her; so good-by.” And
before he could be restrained he pushed himself through the port
into the sea and was drowned.
Midshipman Farragut acted as captain’s aid, quarter-gunner,
powder-boy, and anything that was required of him. He went below
for some primers, when the captain of a gun was struck full in the
face by a sixteen-pound shot, falling back upon the midshipman,
spattering him with blood and tumbling them both down the hatch
together. The blow stunned the midshipman for a moment; but
when he recovered, he rushed again on deck. Captain Porter, seeing
him covered with blood, asked him if he were wounded.
“I believe not, sir.”
“Then, where are the primers?”
This first brought him completely to his senses. He rushed
below again and brought the primers up. Captain Porter fell, stunned
by the windage of a shot, but got to his feet unaided.
Though most other men would have surrendered the ship,
Porter made up his mind to run her towards the shore and beach her
broadside on, fight until the last and then blow her to pieces. An
explosion occurred below and a fire broke out in two places. The
decks were so covered with dead and dying that the men who
remained upright could scarcely move among them. The cockpit
would hold not another wounded man, and the shots which came in
killed men who were under the surgeon’s knife. Out of the two
hundred and fifty-five souls who began the fight only seventy-five,
including officers and boys, remained on the ship fit for duty. Many
of the men, thinking the ship was about to blow up, had jumped
overboard and had drowned or were struggling in the water in the
attempt to swim to land. The long-range shots of the enemy were
striking her at every fire. The Englishmen had the distance
accurately and were battering her to pieces as though at target-
practice.
Captain Porter, at last seeing that resistance was only a waste of
life, called his officers into consultation. But one, Lieutenant
McKnight, could respond, and at 6.20 p.m. the order was given to
haul down the flag.
When the British boarding-officer came over the side, the sight
of the carnage was so shocking that he had to lean against a gun for
support. The force of the “Essex” was forty-six guns and two
hundred and fifty-five men. That of the English, in conservative
estimates, was seventy-three guns and four hundred and twenty-one
men. The English lost five killed and ten wounded. The “Essex” fifty-
eight killed, sixty-six wounded, and thirty-one missing.
Thus died the “Essex” in one of the bloodiest and most
obstinate combats on record.
THE CAPTAIN OF THE MAINTOP

J
ames Jarvis was one of the “young gentlemen” on the
“Constellation” during the war with France. “Young gentlemen”
was what the midshipmen were called in the old naval service,
and Jarvis was the youngest of them all, being just thirteen at the
time of the action with the “Vengeance.” He was the smallest officer
aboard, and his most important duties were those of passing the
word from the quarter-deck forward, and taking his station aloft in
the maintop, where he was learning the mysteries of the maze of
gear which went through the lubber’s-hole or belayed in the top. He
also stood at quarters with his diminutive sword drawn,—a smaller
edition of the lieutenants, who were allowed to wear one epaulette
and who could make a louder noise through the speaking-trumpet
than Jarvis could hope to for years. Down in the midshipmen’s mess,
by virtue of his diminutive stature and tender years, he was not
much interfered with by Wederstrandt, Henry, Vandyke, and the
bigger men. But he fought one or two of the young gentlemen
nearer his age, and, though frequently defeated, stood up as
strongly as possible for what he deemed his rights. He was a manly
little reefer, and up in the maintop, where he was stationed in time
of action, the men swore by him. He was sensible enough not to
give any orders without the professional opinion of one of the old
jackies, who always ventured it with a touch of the cap, a respectful
“Sir,” and perhaps a half-concealed smile, which was more of interest
than amusement. Thirteen was rather a tender age at which to
command men of fifty, but the midshipmen of those days were not
ordinary boys. They went out from their comfortable homes aboard
ships where men were even rougher and less well-disciplined than
they are to-day, and they had either to sink or swim. It was Spartan
treatment; but a year of it made men and sailors of them or else
sent them posting home to their mothers and sisters.
Jarvis loved it, and did his duty like a man. He knew the lead of
all the gear on his mast, and kept his few pieces of brass-work aloft
shining like new. He kept the rigging in his top, even when there
was no occasion for it, coiled down as though for inspection,
although nobody but the topmen and yardmen ever had occasion to
examine it. He was as active as a monkey, and, scorning the
“lubber’s-hole,” went over the futtock-shrouds as smartly as any of
the light-yardmen.
The greatest and probably the only regret of midshipman
Jarvis’s short life was that he had not joined the great frigate before
she met and defeated the “Insurgente” the year before. He wanted
to be in a great action. Nothing seemed to make him feel more of a
man than when the long 18-pounders were fired in broadside at
target-practice. If he had been but a boy, instead of an officer with a
gold-laced cap and a dirk and all the dignities pertaining to those
habiliments, he would have clapped his hands and shouted for sheer
joy. But the eyes of his men were upon him, and so he stood
watching the flight of the shots, and biting hard on his lips he kept
his composure.
Captain Truxton, ever mindful of his midshipmen, had disposed
them in different parts of the ship with regard to their size and
usefulness. The older ones had been given gun-divisions, while the
youngsters were placed on the fo’c’s’le or in the tops, where they
might be of assistance, but would more certainly be out of harm’s
way. Such a thought was not suggested on the “Constellation.” If it
had been, little Jarvis would probably have resigned immediately, or
at the very least have burst into unmanly tears. As it was, he felt
that his post aloft was as important as any on the ship, and he
promised himself that if another Frenchman was sighted he would
stay there whether the mast were up or down.
So, on the 1st of February, 1800, just about a year after the
capture of the “Insurgente,” while they were bowling along under
easy sail, about fifteen miles off Basse Terre, a large sail, which
appeared to be a French frigate, was sighted to the southward.
Jarvis went aloft two ratlines at a time, his heart bounding with joy
at the prospect of the chance of a fight.
On assuring himself that she was a large ship, Captain Truxton
immediately set all sail and took a course which soon brought her
hull above the horizon and showed the Americans beyond a doubt
that she was a ship-of-war of heavier metal than the “Constellation.”
Nothing daunted, Truxton bore on his course until the gun-streaks of
the other vessel could be plainly seen. Instead of showing the same
desire to speak, the stranger held on, pointing a little off his course,
as though anxious to avoid an encounter.
But the breeze, which had been light, now died away altogether,
and the sea became calm. There the two great vessels drifted in
sight of each other all night and part of the following day, awaiting
the wind which would enable them to close. Jarvis was in a fever of
impatience. A half a dozen times he got permission from the officer
of the deck, and with a telescope almost as long as himself,
clambered up to the main-royal to report. There was but one opinion
among the midshipmen who went aloft,—she was a Frenchman. She
could not be anything else.
About two o’clock in the afternoon of the next day, up to the
northward they saw the ripple on the water of the wind they had
been waiting for. The sail-loosers flew aloft, and every sail was
spread to catch it. Soon the “Constellation” was pushing her way
through the water, and the foam was even flying from the wave-tops
here and there. The chase had caught the breeze at about the same
time, and the Americans could see by the line of white under her
bow that she was beginning to leg it at a handsome rate. But the
“Constellation” was in excellent condition for a race, and by degrees
drew up on the other ship, which as they reached her was seen to
lie very low in the water, as though deep-laden. They were sure to
discover who she was before nightfall, so Truxton cleared his ship for
action. Jarvis went aloft to his top and saw the backstays lashed and
the preventer-braces securely hooked and rove. Extra muskets were
carried up into his top for the use of the jackies and marines when
they should come into close quarters, for then the fire of
sharpshooters would be almost as valuable as the shots of the great
guns.
Their work had been over an hour and the sun had set in a
clear sky before the “Constellation” drew up to gunshot distance. It
was moonlight before she came within effective range. The battle-
lanterns were lit, and the long row of lights on the Frenchman
showed that he, too, was prepared for fight. The sky was clear, and
the moon, which was nearly at the full, made the outlines of the
vessels perfectly visible to the men at the guns. Jarvis, from his post
aloft, could plainly see the lines of heads along the poop, and
fancied that he could make out a midshipman almost as young as
he, who was clambering about the maintop of the other vessel. He
heard the beating of a drum and the sound of cheers as the
Frenchmen moved to their quarters.
On the decks below there was not a sound. Truxton had given
his men their orders. There was to be no cheering until there was
something to cheer for. They were to await the order to fire until the
enemy was close aboard, and then, and not until then, was the
broadside to be delivered. The division-officers had gone about
quietly repeating these commands to the gun-captains, and there
was nothing further to say. Only to wait until the battle began. Jarvis
repeated to his topmen, word for word, the instructions he had
received, that in their aim particular attention was to be paid to the
officers of the enemy.
Soon a gun from the after-battery of the Frenchman was fired.
This was followed shortly by all the guns that would bear. Some of
the shots crashed into the hull of the “Constellation,” and one of
them killed several men. The division-officers glanced appealingly to
Truxton, in the hope of the order to fire; but he merely held up his
hand. Again the broadside came, and men seemed to be falling
everywhere. The strain below and aloft was terrific. But the officers
stood steadily, with a word of encouragement here and there, and
the men did not flinch.
THE “CONSTELLATION” AND THE “VENGEANCE”

At last the “Constellation” came abreast the after-ports of the


Frenchman, and Truxton, throwing her off a little, so that all his
broadside would bear in a diagonal direction, loudly shouted the
order to fire.
The telling broadside was delivered, and the battle was on in
earnest. To those aloft the crash of the long eighteens into the hull
of the enemy at every other downward roll of the “Constellation”
showed how well the American gunners had learned to shoot, while
the short bark of the cannonades and the shrieks in the brief pauses
from the decks of the Frenchman told of the terrible effects of the
fire among the enemy. The guns of the Frenchman were well served
and rapidly fired, but they were aiming on the upward roll of the
sea, and their shots went high. Several balls from the smaller pieces
had lodged in the foremast and mainmast, and one had struck just
below the futtock-band of the maintop, where Jarvis was, and sent
the splinters flying up and all about him. Yard-arm to yard-arm they
sailed for three long, bloody hours, until the firing of the Frenchman
gradually slackened and then stopped almost altogether. The
Americans had suffered less on the decks than aloft, and Jarvis’s
topmen were employed most of the time in splicing and re-reeving
gear. The discharge of the “Constellation’s” broadside-guns did not
diminish for a moment, and so fast was the firing that many of the
guns became overheated, and the men had to crawl out of the
exposed ports to draw up buckets of water to cool them.
At about midnight Truxton managed to draw ahead of his
adversary in the smoke, and, taking a raking position, sent in such a
broadside that the Frenchman was silenced completely.
Jarvis and the men in the maintop had little time to use their
muskets. Several long shots had struck the mast, and almost every
shroud and backstay had been carried away. As the “Constellation”
bore down upon her adversary to deal her the death-blow, the mast
began swaying frightfully. There was a cry from the men at Jarvis’s
side, and the marines and topmen began dropping through the
lubber’s-hole, swinging themselves down the sides of the swaying
mast by whatever gear they could lay their hands to.
Jarvis did not move. One of the older seamen took him by the
shoulder and urged him to go below. The mast was going, he said,
and it meant certain death to stay aloft.
Little Jarvis smiled at him. “This is my post of duty,” he replied,
“and I am going to stay here until ordered below.”
At this moment a terrific crackling was heard, and the old man-
o’-warsman went over the edge of the top. All the strain was on one
or two of the shrouds, and, just as he reached the deck, with a
tremendous crash the great mast went over the side.
Jarvis had kept his promise to stay by his mast whether it was
up or down.
The Frenchman, not so badly injured aloft, took advantage of
the condition of the “Constellation,” and, slowly making sail before
the wreck was cleared away, faded into the night. It was afterwards
discovered that she was the “Vengeance,” of fifty-two guns. She
succeeded in reaching Curaçoa in a sinking condition.
When the news of the fight reached home, Congress gave
Truxton a medal and a sword, and prize money to the officers and
crew.
For little Jarvis, the midshipman, who preferred to die at his
post, Congress passed a special resolution, which read:
“Resolved, That the conduct of James Jarvis, a midshipman in
said frigate, who gloriously preferred certain death to an
abandonment of his post, is deserving of the highest praise, and that
the loss of so promising an officer is a subject of national regret.”
History does not show an instance of nobler self-sacrifice, and
no such honor as this special act of Congress was received by a boy
before or since.
CUSHING AND THE “ALBEMARLE”

A
lthough the Civil War furnished many instances of conspicuous
gallantry, so many that most of them remain to-day
comparatively unknown, none was more notable than the
torpedo exploit of Lieutenant William Barker Cushing. There have
been several similar expeditions in our naval history. Before Tripoli,
Richard Somers made the ill-fated attempt with the “Intrepid,” and in
the war with Spain, Richmond Hobson sunk the “Merrimac.” There is
no question that the personal and sentimental aspects of these three
hazardous enterprises are similar. All three men were young, and
each one knew that he took his life in his hands. Somers, rather than
be captured with his powder, destroyed both his ship and himself.
Hobson sunk the “Merrimac,” but did not succeed in getting her
athwart the channel. Cushing, in a torpedo-launch, went under the
guns of the enemy, and escaped both death and imprisonment. On
the enemy the moral effect of all three exploits must have been the
same. Professionally, Cushing’s exploit has just this distinction: he
was successful. Like Decatur in the recapture of the “Philadelphia,”
he carried out in every detail the plans he had made. And upon his
success the way was opened for the Union fleet, and the hopes of
the Confederates fled, for only two seaports in the South—
Charleston and Wilmington—remained open to them.
After the great success of the “Merrimac” in Hampton Roads,
the Confederates determined to construct a vessel of similar design
for use in the Southern rivers and sounds. Under great difficulties
they built the “Albemarle” on the Roanoke River, and carried her into
action almost before the last rivet was driven. She was a formidable
craft in those days, and the shots from the vessels of the Northern
fleet went harmlessly against her iron sides to break and fly into a
thousand pieces. On the 5th of May the “Albemarle” had another
fight with a larger fleet of Union vessels, which had gathered to hem
in and disable her. During the action the “Sassacus” saw an
opportunity to ram her, and, going ahead at full speed, struck the
ram a terrific blow amidships. The bow of the “Sassacus” was
literally torn to pieces by the impact, and the “Albemarle,” though
heeling over and in danger of sinking for a time, finally righted and
pulled out of the action uninjured, but by no means disabled. All of
the vessels of the squadron kept up a heavy fire upon her, but she
went on to her anchorage up the river, where a few repairs made
her as good as ever.
It looked to the Unionists as though the story of the “Merrimac”
with the “Congress” and the “Cumberland” was about to be
repeated; that the “Albemarle” in course of time would come down
at her leisure and destroy all Northern vessels in those waters. To
make matters worse, the Unionists learned that another vessel of a
similar type was nearly completed, and that the two vessels would
attack at the same time,—a combination which, with their consorts,
seemed irresistible. Something had to be done if the command of
the sounds of the Carolinas was to remain with the navy of the
North.
But during the summer of 1864 two steam launches rigged up
as torpedo-boats, the invention of Engineer J. L. Long, were fitted
out at New York and brought down through the canals to Albemarle
Sound. The bows of the boats were cut under and decked over, and
the engines were so built that when covered and moving at a low
rate of speed they made little or no noise. A spar ten or fifteen feet
long, which carried a torpedo and a firing attachment, projected
forward over the bow, and a small howitzer was also mounted
forward where it would be useful to repel attack.
The government had decided to make a night attempt on the
“Albemarle,” and the honor of the command of the expedition was
bestowed on Lieutenant Cushing, who had half a dozen times before
received the thanks of the secretary of the navy for gallantry in
action off Cape Fear River.
The expedition was favored by the inactivity of the
Confederates. The “Albemarle” lay alongside the dock at Plymouth
awaiting the completion of her sister-ship, but this needless delay
gave Cushing the opportunity he wanted.
The Confederates were fully aware of the plans of the Unionist’s
navy, and a thousand soldiers remained to guard the “Albemarle”
from land attack as well as to act as sentries for a distance along the
river bank. To provide against torpedoes, a line of great cypress logs
was boomed off her sides at a distance of twenty to thirty feet, so
that it seemed impossible to come within striking distance. Besides
this, the smaller guns of the ram were trained up and down the river,
—which here was but one hundred and fifty yards wide,—to sweep
the entire area over which the attacking party had to pass.
But Cushing, like Decatur, rejoiced at obstacles. He was only
twenty-one, but he carried a man’s head on his broad shoulders, and
the planning of such an expedition down to the smallest detail was a
task which he entered into with judgment and enthusiasm,
ingredients as rare as they are necessary in such a desperate
enterprise.
After a week spent in preparation and experiment, the gunboat
“Otsego” brought the launch to the mouth of the river, where
Cushing cast off and pointed his bow toward Plymouth, towing a
cutter full of armed men, who were to capture, if possible, a
Confederate guard,—which had been set in a schooner near the
sunken “Southfield,”—to prevent their giving the alarm. But the
expedition started badly, for the launch ran aground on a bar. Before
Cushing could float her again it was too late to make the attempt.
Cushing and his boat’s crews then returned to the “Otsego.”
The next night was black and squally, with occasional showers
of rain. They could only make out the loom of the shore by straining
their eyes into the darkness. Cushing was as cool as though taking
shore-liberty. As he shook hands with the “Otsego’s” officers he
paused at the gangway to say, with a laugh,—
“Well, here goes for another stripe or a coffin.”
They crept slowly up the river, keeping close to the bank, under
the shadow of the reeds and trees. The little engine, covered with
tarpaulins, made so little sound that the men in the cutter towing
astern could hardly hear it. There was not a sound except the
plashing of the gusts of rain and the ripple of the water as the little
craft moved steadily on. Cushing knew he must be passing some of
the pickets now, so not a word even in whispers was spoken. Every
man had his duty and knew when to do it. Acting Ensign William
Howarth was aft at Cushing’s side. Acting Master’s Mate John
Woodman, who knew the river, was next to him. The other officers
were Acting Master’s Mate Thomas S. Gay, Acting Assistant-
Paymaster Francis H. Swan, and Acting Third-Assistant-Engineers
Charles L. Steever and William Stotesbury.
By half-past two a.m., about a mile below Plymouth, where the
“Albemarle” lay, they came upon the submerged “Southfield,” and
could just make out the lines of the guard-schooner. The machinery
of the launch was slowed, almost stopped, for Cushing had decided
to get by her if he could without a fight. It was a moment of utmost
anxiety, and every man was prepared for the attack. But there was
no sign of discovery from the schooners, and in ten minutes the little
expedition had passed up the river in safety.
But only the first danger of discovery was over. Between the
“Southfield” and Plymouth the bank was guarded by a double line of
sentries, and the men in the boats, now moving more quickly, could
see the red glare of the smouldering fires reaching all the way to
town. As they came to the point beyond which the ram was lying,
they found, to their delight, that the fires which should have been
brightly burning were smouldering in the rain. There was no sign of
a man to be made out anywhere, and Cushing pushed on directly for
the “Albemarle,” which he could now see plainly as she lay at the
wharf, grim and menacing, but without a sign of life.
Suddenly from the shore there came the sharp bark of a dog. To
the ears of Cushing and his men in the deep silence and anxiety of
the moment it sounded like the report of a Dahlgren. There was a
cry from a sentry and a challenge, followed by a musket-shot, and
the bullet flew over the boats and struck the water fifty feet away
with a vicious ping that sounded not less loud than the report itself.
There was another challenge, and in a moment the cries came from
everywhere. Other dogs began barking, and it seemed as though the
whole town was aroused. The sentries on both sides of the stream
threw inflammable material on the smouldering fires, and in a
moment the river was as bright as day.
Realizing that further concealment was useless, Cushing himself
cast off the towline of the cutter, and telling the men in her to row
for their lives, gave the engineer the order, “Four bells, ahead full
speed,” setting the nose of the launch directly for the ram. The
sparks flew up from her stack, and the dark water churned up in
masses of foam under her stern, as like a sentient thing she leaped
forward on her deadly mission. It was then that Cushing discovered
for the first time the line of torpedo booms which guarded the ram.
In facing the musketry-fire and the great guns of their enormous
adversary the task of getting close enough to reach her seemed
impossible.
Cushing knew that if he was to get over the log booms he must
strike them fair; then perhaps he could slide over within striking
distance. He shifted his helm, and making a wide sweep out into the
stream, gathered all the headway he could and came down into the
very jaws of the great monster. A tremendous volley from the shot-
guns and muskets of the sentries greeted them, and Paymaster
Swan was wounded. Cushing received a charge of buckshot in the
back of his coat and had the sole of his shoe torn off, but these were
the only shots which took effect.
Cushing here shouted, in a loud voice, “Leave the ram; we’re
going to blow you up!” hoping to create a panic. But the
Confederates continued firing, and succeeded in getting in two
howitzer-shots, one of which felled a man by Cushing’s side. At this
moment, Gay, up forward in the launch, took careful aim with the
howitzer, and sent a charge in the midst of the Confederate crew.
Then with a slight jar the sled-like bow rose on the boom. She
balanced a second, and slid over within the enclosure, half full of
water, but within reaching distance.
One of the great guns of the “Albemarle,” a hundred-pounder,
protruded from a broadside port directly in front of them, and they
could see the gun-crew frantically training the gun and trying to
depress the muzzle enough to bear on them. It was a matter of
seconds now. Who would fire first? Cushing had lowered the
torpedo-spar, and as soon as he had it well under the overhang he
detached it, then waited until he heard the torpedo strike the hull,
when he pulled the trigger-line. He was not a fraction of a second
too soon, for the two concussions were almost simultaneous. There
was a muffled roar from below the great vessel, and a column of
water shot out from under her as she lifted on the wave. The shock
of the hundred-pounder was terrific, and it seemed as if the frail
launch had been blown to pieces. But Cushing had been too quick
for them. The charge of canister passed a few feet over their heads
and scattered in the river beyond.
The work of the gallant crew was done. Cushing had made a
hole in the “Albemarle” large enough to have driven a wagon
through. The great wave of the torpedo rose and went completely
over the launch, swamping her alongside and throwing her men into
the water. All of them got to the booms safely. Here Cushing paused
a moment to throw off his outer clothing, while the Confederates on
the banks were shouting to the men to surrender. Several of them,
being unable to swim, did so; but Cushing, calling to the others to
follow him, plunged boldly into the water and struck off down the
stream. He was a powerful swimmer, but the night was cold, and he
knew that he could not keep up very long. But he swam for half an
hour, and he came upon Woodman in the middle of the stream,
almost exhausted. Though almost entirely fagged out himself, he
tried to help the mate towards the shore. Finding that he was being
pulled down and unable to save the other, Cushing struggled on, and
reached the shoal water more dead than alive. Here he lay among
the reeds until dawn, when he learned from a negro how complete
had been his success. At last, after almost twenty-four hours’
exposure, he succeeded in finding one of the enemy’s deserted
picket-skiffs, and managed under cover of the second night to pull
off to the Federal “Valley City,” which he reached at eleven o’clock at
night, and was hauled aboard completely exhausted from his labor
and exposure. Only one other of his crew reached a place of safety.
Woodman and Samuel Higgins, the fireman, were drowned. The
others went ashore and surrendered or were captured.
This service, because of the great benefit to the Union cause
and the daring manner in which it had been performed, made
Cushing the hero of the year. Congress passed a vote of thanks and
promoted him to the rank of lieutenant-commander, which he held
until 1872, when he became a commander.
He did not long enjoy his honors, for two years later he died of
brain fever, in Washington, at the age of thirty-two. Had he lived he
would have been but fifty-six years of age at the outbreak of the war
with Spain, and would have been one of the ranking officers in
active service of the new navy.
SOMERS AND THE “INTREPID”

A
mong the young officers of Commodore Preble’s squadron
before Tripoli there was a tall, dark, melancholy-looking fellow
of about twenty-five. His name was Richard Somers and his
command was the “Nautilus,” a little schooner of twelve guns and a
hundred men. He had been with Decatur and Stewart, a junior
officer on Commodore Barry’s “United States” in the war with Spain,
and the friendship formed in those early days had been cemented by
a score of thrilling adventures which had drawn them more closely
together than brothers. Charles Stewart, before Decatur’s promotion
to post-captain, had been the second in command to Preble, and his
vessel, the “Siren,” had taken a prominent part in all the many
actions with the Tripolitan forts and gunboats. He was a year or so
older than his companions and had drifted a little away from them.
But Decatur and Somers were inseparable. Some bond outside of
mere professional sympathy and environment existed between them,
and there seemed to be no thought of the one that the other did not
share. The difference in their temperaments was marked. Decatur
was bold, domineering, and impetuous. Somers was quiet, mild, and
ever avoided the quarrel which Decatur too often sought. But under
the quiet exterior men had found a will like iron and the willingness
to dare and do anything that came within the province of his
profession. He was thoughtful, but not so quiet that he could not
enter into the gayety of the mess; he was mild, but not so mild that
he would overlook shortcomings among his men or brook any slight
upon his office or his reputation.
In the old days on the “United States” there happened an affair
which immediately established his reputation as an officer and a
man. At first he was not understood. His brother midshipmen,
mistaking the reserve of his manner for weakness, did not hesitate
before they had been aboard with him a month to take advantage of
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookname.com

You might also like