100% found this document useful (1 vote)
133 views

C Programming From Problem Analysis to Program Design 5th 5th Edition D. S. Malik pdf download

The document provides information about various programming textbooks by D.S. Malik, including the 5th edition of 'C++ Programming: From Problem Analysis to Program Design' and other related titles. It includes links for instant digital downloads of these books in multiple formats. The content covers a wide range of programming concepts and methodologies, structured in a detailed table of contents.

Uploaded by

meykemehyo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
133 views

C Programming From Problem Analysis to Program Design 5th 5th Edition D. S. Malik pdf download

The document provides information about various programming textbooks by D.S. Malik, including the 5th edition of 'C++ Programming: From Problem Analysis to Program Design' and other related titles. It includes links for instant digital downloads of these books in multiple formats. The content covers a wide range of programming concepts and methodologies, structured in a detailed table of contents.

Uploaded by

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

C Programming From Problem Analysis to Program

Design 5th 5th Edition D. S. Malik pdf download

https://ebookgate.com/product/c-programming-from-problem-
analysis-to-program-design-5th-5th-edition-d-s-malik/

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


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

Java Programming From Problem Analysis to Program Design


4th Edition D. S. Malik

https://ebookgate.com/product/java-programming-from-problem-analysis-
to-program-design-4th-edition-d-s-malik/

ebookgate.com

C Programming From Problem Analysis to Program Design 4th


Edition Barbara Doyle

https://ebookgate.com/product/c-programming-from-problem-analysis-to-
program-design-4th-edition-barbara-doyle/

ebookgate.com

C Programming Program Design Including Data Structures 7th


Edition D. S. Malik

https://ebookgate.com/product/c-programming-program-design-including-
data-structures-7th-edition-d-s-malik/

ebookgate.com

C Programming Program Design Including Data Structures 6th


Edition D. S. Malik

https://ebookgate.com/product/c-programming-program-design-including-
data-structures-6th-edition-d-s-malik/

ebookgate.com
C Programming Program design including data structures
5ed. Edition Malik D.S.

https://ebookgate.com/product/c-programming-program-design-including-
data-structures-5ed-edition-malik-d-s/

ebookgate.com

Design and Analysis of Experiments 5th ed Edition Douglas


C. Montgomery

https://ebookgate.com/product/design-and-analysis-of-experiments-5th-
ed-edition-douglas-c-montgomery/

ebookgate.com

Frommer s Irreverent Guide to Washington D C 5th Ed 2004


Irreverent Guides 5th Edition Tom Price

https://ebookgate.com/product/frommer-s-irreverent-guide-to-
washington-d-c-5th-ed-2004-irreverent-guides-5th-edition-tom-price/

ebookgate.com

Chandler and Grant s Glaucoma 5th Edition Malik Kahook

https://ebookgate.com/product/chandler-and-grant-s-glaucoma-5th-
edition-malik-kahook/

ebookgate.com

Principles of Real Analysis 2nd Edition S C Malik

https://ebookgate.com/product/principles-of-real-analysis-2nd-edition-
s-c-malik/

ebookgate.com
C++ PROGRAMMING:
FROM PROBLEM ANALYSIS TO PROGRAM DESIGN

FIFTH EDITION

D.S. MALIK

Australia  Brazil  Japan  Korea  Mexico  Singapore  Spain  United Kingdom  United States
C++ Programming: From Problem Analysis
to Program Design, Fifth Edition For product information and technology assistance, contact us at
Cengage Learning Customer & Sales Support, 1-800-354-9706
D.S. Malik For permission to use material from this text or product, submit
all requests online at www.cengage.com/permissions
Executive Editor: Marie Lee
Further permissions questions can be emailed to
Acquisitions Editor: Amy Jollymore permissionrequest@cengage.com
Senior Product Manager: Alyssa Pratt
Editorial Assistant: Zina Kresin Library of Congress Control Number: 2009942948
Content Project Manager: Matthew ISBN-13: 978-0-538-79808-2
Hutchinson
ISBN-10: 0-538-79808-4
Art Director: Faith Brosnan
Print Buyer: Julio Esperas Course Technology
20 Channel Center Street
Cover Designer: Roycroft Design/
Boston, MA 02210
www.roycroftdesign.com
USA
Cover Photo: ª Guntmar Fritz/Masterfile
Some of the product names and company names used in this
Proofreader: Green Pen QA book have been used for identification purposes only and may
Indexer: Elizabeth Cunningham be trademarks or registered trademarks of their respective
Compositor: Integra manufacturers and sellers.
Any fictional data related to persons or companies or URLs used
throughout this book is intended for instructional purposes only.
ª 2011 Course Technology, Cengage Learning At the time this book was printed, any such data was fictional
ALL RIGHTS RESERVED. No part of this work and not belonging to any real persons or companies.
covered by the copyright herein may be Course Technology, a part of Cengage Learning, reserves the
reproduced, transmitted, stored or used in any right to revise this publication and make changes from time to
form or by any means graphic, electronic, or time in its content without notice.
mechanical, including but not limited to
photocopying, recording, scanning, digitizing, The programs in this book are for instructional purposes only.
taping, Web distribution, information They have been tested with care, but are not guaranteed
networks, or information storage and retrieval for any particular intent beyond educational purposes. The
systems, except as permitted under Section author and the publisher do not offer any warranties or
107 or 108 of the 1976 United States Copyright representations, nor do they accept any liabilities with respect
Act, without the prior written permission of to the programs.
the publisher. Cengage Learning is a leading provider of customized
learning solutions with office locations around the globe,
including Singapore, the United Kingdom, Australia, Mexico,
Brazil and Japan. Locate your local office at:
www.cengage.com/global
Cengage Learning products are represented in Canada
by Nelson Education, Ltd.
To learn more about Course Technology, visit
www.cengage.com/coursetechnology
Purchase any of our products at your local college store or at
our preferred online store www.CengageBrain.com

Printed in the United States of America


1 2 3 4 5 6 7 16 15 14 13 12 11 10
TO

My Daughter

Shelly Malik
This page intentionally left blank
B RIEF C ONTENTS

1. An Overview of Computers and Programming Languages 1

2. Basic Elements of C++ 27

3. Input/Output 117

4. Control Structures I (Selection) 175

5. Control Structures II (Repetition) 247

6. User-Defined Functions I 319

7. User-Defined Functions II 361

8. User-Defined Simple Data Types, Namespaces,


and the string Type 433

9. Arrays and Strings 485

10. Applications of Arrays (Searching and Sorting)


and the vector Type 563

11. Records (structs) 611

12. Classes and Data Abstraction 649

13. Inheritance and Composition 723

14. Pointers, Classes, Virtual Functions, and Abstract Classes 793

15. Overloading and Templates 861

16. Exception Handling 951

17. Recursion 991


vi | C++ Programming: From Problem Analysis to Program Design, Fifth Edition

18. Linked Lists 1023

19. Stacks and Queues 1115

APPENDIX A Reserved Words 1215

APPENDIX B Operator Precedence 1217

APPENDIX C Character Sets 1219

APPENDIX D Operator Overloading 1223

APPENDIX E Additional C++ Topics 1225

APPENDIX F Header Files 1247

APPENDIX G Memory Size on a System and Random


Number Generator 1257

APPENDIX H Standard Template Library (STL) 1259

APPENDIX I Answers to Odd-Numbered Exercises 1301

INDEX 1331
TABLE OF C ONTENTS

Preface xxvii

AN OVERVIEW OF COMPUTERS AND PROGRAMMING


1 LANGUAGES 1
Introduction 2

A Brief Overview of the History of Computers 2

Elements of a Computer System 3


Hardware 4
Central Processing Unit and Main Memory 4
Input /Output Devices 5
Software 6

The Language of a Computer 6

The Evolution of Programming Languages 8

Processing a C++ Program 10

Programming with the Problem


Analysis–Coding–Execution Cycle 12

Programming Methodologies 20
Structured Programming 20
Object-Oriented Programming 20

ANSI/ISO Standard C++ 22

Quick Review 22

Exercises 23
viii | C++ Programming: From Problem Analysis to Program Design, Fifth Edition

BASIC ELEMENTS OF C++ 27


2 A C++ Program 28
The Basics of a C++ Program 31
Comments 32
Special Symbols 32
Reserved Words (Keywords) 33
Identifiers 33
Whitespaces 34
Data Types 35
Simple Data Types 35
Floating-Point Data Types 38

Arithmetic Operators and Operator Precedence 39


Order of Precedence 43

Expressions 44
Mixed Expressions 45

Type Conversion (Casting) 47

string Type 49
Input 50
Allocating Memory with Constants and Variables 50
Putting Data into Variables 53
Assignment Statement 53
Saving and Using the Value of an Expression 56
Declaring and Initializing Variables 57
Input (Read) Statement 58
Variable Initialization 61

Increment and Decrement Operators 65


Output 67
Preprocessor Directives 75
namespace and Using cin and cout in a Program 76
Using the string Data Type in a Program 76

Creating a C++ Program 77

Debugging: Understanding and Fixing Syntax Errors 80


Table of Contents | ix

Program Style and Form 84


Syntax 84
Use of Blanks 85
Use of Semicolons, Brackets, and Commas 85
Semantics 85
Naming Identifiers 85
Prompt Lines 86
Documentation 87
Form and Style 87

More on Assignment Statements 89

Programming Example: Convert Length 91

Programming Example: Make Change 94

Quick Review 98

Exercises 100

Programming Exercises 109

INPUT/OUTPUT 117
3 I/O Streams and Standard I/O Devices 118
cin and the Extraction Operator >> 119

Using Predefined Functions in a Program 124


cin and the get Function 127
cin and the ignore Function 128
The putback and peek Functions 130
The Dot Notation between I/O Stream Variables
and I/O Functions: A Precaution 132

Input Failure 133


The clear Function 135

Output and Formatting Output 137


setprecision Manipulator 137
fixed Manipulator 138
showpoint Manipulator 139
setw 142
x | C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Additional Output Formatting Tools 144


setfill Manipulator 144
left and right Manipulators 146

Input/Output and the string Type 148

Debugging: Understanding Logic Errors


and Debugging with cout Statements 149

File Input/Output 152

Programming Example: Movie Tickets Sale


and Donation to Charity 156

Programming Example: Student Grade 162

Quick Review 165

Exercises 166

Programming Exercises 170

CONTROL STRUCTURES I(SELECTION) 175


4 Control Structures 176

Relational Operators 177


Relational Operators and Simple Data Types 178
Comparing Characters 179
Relational Operators and the string Type 180

Logical (Boolean) Operators and Logical Expressions 182


Order of Precedence 184
int Data Type and Logical (Boolean) Expressions 187
bool Data Type and Logical (Boolean) Expressions 188

Selection: if and if...else 188


One-Way Selection 189
Two-Way Selection 191
Compound (Block of) Statements 195
Multiple Selections: Nested if 195
Comparing if...else Statements with a Series of
if Statements 198
Short-Circuit Evaluation 199
Table of Contents | xi

Comparing Floating-Point Numbers for Equality:


A Precaution 200
Associativity of Relational Operators: A Precaution 201
Avoiding Bugs by Avoiding Partially Understood
Concepts and Techniques 203
Input Failure and the if Statement 206
Confusion between the Equality Operator (==) and
the Assignment Operator (=) 209
Conditional Operator (?:) 211
Program Style and Form (Revisited): Indentation 211

Using Pseudocode to Develop, Test, and Debug a Program 212

switch Structures 215


Avoiding Bugs by Avoiding Partially Understood Concepts and
Techniques (Revisited) 221

Terminating a Program with the assert Function 223

Programming Example: Cable Company Billing 225

Quick Review 231

Exercises 232

Programming Exercises 241

CONTROL STRUCTURES II (REPETITION) 247


5 Why Is Repetition Needed? 248

while Looping (Repetition) Structure 249

Designing while Loops 251


Case 1: Counter-Controlled while Loops 252
Case 2: Sentinel-Controlled while Loops 255
Case 3: Flag-Controlled while Loops 259
Case 4: EOF-Controlled while Loops 263
eof Function 263
More on Expressions in while Statements 268

Programming Example: Fibonacci Number 269

for Looping (Repetition) Structure 273

Programming Example: Classifying Numbers 281


xii | C++ Programming: From Problem Analysis to Program Design, Fifth Edition

do...while Looping (Repetition) Structure 284


Choosing the Right Looping Structure 289

break and continue Statements 289

Nested Control Structures 291

Avoiding Bugs by Avoiding Patches 296

Debugging Loops 299

Quick Review 300

Exercises 301

Programming Exercises 313

USER-DEFINED FUNCTIONS I 319


6 Predefined Functions 320

User-Defined Functions 324

Value-Returning Functions 324


Syntax: Value-Returning Functions 326
Syntax: Formal Parameter List 326
Function Call 326
Syntax: Actual Parameter List 327
return Statement 327
Syntax: return Statement 327
Function Prototype 331
Syntax: Function Prototype 332
Value-Returning Functions: Some Peculiarity 333
More Examples of Value-Returning Functions 335
Flow of Execution 340

Programming Example: Largest Number 341

Programming Example: Cable Company 343

Quick Review 349

Exercises 350

Programming Exercises 356


Table of Contents | xiii

USER-DEFINED FUNCTIONS II 361


7 Void Functions 362

Value Parameters 367

Reference Variables as Parameters 368

Value and Reference Parameters


and Memory Allocation 372

Reference Parameters and Value-Returning Functions 382

Scope of an Identifier 382

Global Variables, Named Constants, and Side Effects 386

Static and Automatic Variables 391

Debugging: Using Drivers and Stubs 392

Function Overloading: An Introduction 395

Functions with Default Parameters 396

Programming Example: Classify Numbers 399

Programming Example: Data Comparison 404

Quick Review 414

Exercises 416

Programming Exercises 424

USER-DEFINED SIMPLE DATA TYPES,


8 NAMESPACES, AND THE string TYPE 433

Enumeration Type 434


Declaring Variables 436
Assignment 436
Operations on Enumeration Types 437
Relational Operators 437
Input /Output of Enumeration Types 438
Functions and Enumeration Types 440
Declaring Variables When Defining the Enumeration Type 442
xiv | C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Anonymous Data Types 442


typedef Statement 443

Programming Example: The Game of Rock,


Paper, and Scissors 444

Namespaces 452

string Type 458


Additional string Operations 461

Programming Example: Pig Latin Strings 471

Quick Review 475

Exercises 477

Programming Exercises 481

ARRAYS AND STRINGS 485


9 Arrays 487
Accessing Array Components 488
Processing One-Dimensional Arrays 491
Array Index Out of Bounds 494
Array Initialization During Declaration 495
Partial Initialization of Arrays During Declaration 496
Some Restrictions on Array Processing 496
Arrays as Parameters to Functions 497
Constant Arrays as Formal Parameters 498
Base Address of an Array and Array in Computer Memory 501
Functions Cannot Return a Value of the Type Array 503
Integral Data Type and Array Indices 506
Other Ways to Declare Arrays 507

Searching an Array for a Specific Item 507

C-Strings (Character Arrays) 510


String Comparison 512
Reading and Writing Strings 514
String Input 514
String Output 515
Table of Contents | xv

Specifying Input/Output Files at Execution Time 516


string Type and Input/Output Files 516

Parallel Arrays 517

Two- and Multidimensional Arrays 518


Accessing Array Components 520
Two-Dimensional Array Initialization During Declaration 521
Two-Dimensional Arrays and Enumeration Types 521
Initialization 524
Print 525
Input 525
Sum by Row 525
Sum by Column 526
Largest Element in Each Row and Each Column 526
Passing Two-Dimensional Arrays as Parameters to Functions 527
Arrays of Strings 530
Arrays of Strings and the string Type 530
Arrays of Strings and C-Strings (Character Arrays) 530
Another Way to Declare a Two-Dimensional Array 531
Multidimensional Arrays 532

Programming Example: Code Detection 534

Programming Example: Text Processing 540

Quick Review 547

Exercises 548

Programming Exercises 558

APPLICATIONS OF ARRAYS (SEARCHING AND SORTING)


10 AND THE Vector TYPE 563

List Processing 564


Searching 564
Bubble Sort 565
Selection Sort 569
Insertion Sort 572
Binary Search 576
xvi | C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Performance of Binary Search 580

vector Type (class) 580

Programming Example: Election Results 585

Quick Review 601

Exercises 603

Programming Exercises 606

RECORDS ( structS) 611


11 Records (structs) 612
Accessing struct Members 614
Assignment 616
Comparison (Relational Operators) 617
Input /Output 618
struct Variables and Functions 618
Arrays versus structs 619
Arrays in structs 620
structs in Arrays 622
structs within a struct 624

Programming Example: Sales Data Analysis 628

Quick Review 642

Exercises 642

Programming Exercises 645

CLASSES AND DATA ABSTRACTION 649


12 Classes 650
Unified Modeling Language Class Diagrams 654
Variable (Object) Declaration 654
Accessing Class Members 655
Built-in Operations on Classes 656
Assignment Operator and Classes 657
Class Scope 657
Table of Contents | xvii

Functions and Classes 658


Reference Parameters and Class Objects (Variables) 658
Implementation of Member Functions 659
Accessor and Mutator Functions 664
Order of public and private Members of a Class 667
Constructors 669
Invoking a Constructor 671
Invoking the Default Constructor 671
Invoking a Constructor with Parameters 671
Constructors and Default Parameters 674
Classes and Constructors: A Precaution 674
Arrays of Class Objects (Variables) and Constructors 675
Destructors 677

Data Abstraction, Classes, and Abstract Data Types 678

A struct Versus a class 680

Information Hiding 681

Executable Code 685

Static Members of a Class 691

Programming Example: Candy Machine 697

Quick Review 711

Exercises 713

Programming Exercises 718

INHERITANCE AND COMPOSITION 723


13 Inheritance 724
Redefining (Overriding) Member Functions
of the Base Class 727
Constructors of Derived and Base Classes 734
Destructors in a Derived Class 742
Multiple Inclusions of a Header File 743
C++ Stream Classes 744
Protected Members of a Class 746
xviii | C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Inheritance as public, protected, or private 746


(Accessing protected Members in the Derived Class) 747

Composition (Aggregation) 750

Object-Oriented Design (OOD) and


Object-Oriented Programming (OOP) 755
Identifying Classes, Objects, and Operations 757

Programming Example: Grade Report 758


Quick Review 779

Exercises 780
Programming Exercises 787

POINTERS, CLASSES, VIRTUAL FUNCTIONS,


14 AND ABSTRACT CLASSES 793
Pointer Data Type and Pointer Variables 794
Declaring Pointer Variables 794

Address of Operator (&) 795


Dereferencing Operator (*) 796

Classes, Structs, and Pointer Variables 800


Initializing Pointer Variables 803

Dynamic Variables 803


Operator new 804
Operator delete 805

Operations on Pointer Variables 807

Dynamic Arrays 809


Functions and Pointers 812
Pointers and Function Return Values 812
Dynamic Two-Dimensional Arrays 813

Shallow versus Deep Copy and Pointers 816

Classes and Pointers: Some Peculiarities 818


Destructor 818
Assignment Operator 820
Copy Constructor 821
Table of Contents | xix

Inheritance, Pointers, and Virtual Functions 828


Classes and Virtual Destructors 835

Abstract Classes and Pure Virtual Functions 835

Address of Operator and Classes 844

Quick Review 846

Exercises 849

Programming Exercises 857

OVERLOADING AND TEMPLATES 861


15 Why Operator Overloading Is Needed 862

Operator Overloading 863


Syntax for Operator Functions 864
Overloading an Operator: Some Restrictions 864
Pointer this 865
Friend Functions of Classes 870
Operator Functions as Member Functions and Nonmember
Functions 873
Overloading Binary Operators 876
Overloading the Stream Insertion (<<) and Extraction (>>)
Operators 882
Overloading the Assignment Operator (=) 887
Overloading Unary Operators 895
Operator Overloading: Member versus Nonmember 901
Classes and Pointer Member Variables (Revisited) 902
Operator Overloading: One Final Word 902

Programming Example: Clock Type 902

Programming Example: Complex Numbers 911

Overloading the Array Index (Subscript) Operator ([]) 916

Programming Example: Newstring 918

Function Overloading 924


xx | C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Templates 925
Function Templates 925
Class Templates 927

Quick Review 935

Exercises 937

Programming Exercises 942

EXCEPTION HANDLING 951


16 Handling Exceptions within a Program 952
C++ Mechanisms of Exception Handling 956
try/catch Block 956
Using C++ Exception Classes 963

Creating Your Own Exception Classes 967


Rethrowing and Throwing an Exception 973

Exception-Handling Techniques 978


Terminate the Program 978
Fix the Error and Continue 978
Log the Error and Continue 980

Stack Unwinding 980

Quick Review 984

Exercises 986

Programming Exercises 989

RECURSION 991
17 Recursive Definitions 992
Direct and Indirect Recursion 995
Infinite Recursion 995

Problem Solving Using Recursion 996


Tower of Hanoi: Analysis 1005

Recursion or Iteration? 1006


Table of Contents | xxi

Programming Example: Converting a Number from


Binary to Decimal 1007
Programming Example: Converting a Number from
Decimal to Binary 1011
Quick Review 1014

Exercises 1015
Programming Exercises 1018
LINKED LISTS 1023
18 Linked Lists 1024
Linked Lists: Some Properties 1025
Deletion 1031
Building a Linked List 1032

Linked List as an ADT 1037


Structure of Linked List Nodes 1038
Member Variables of the class linkedListType 1038
Linked List Iterators 1039
Print the List 1045
Length of a List 1045
Retrieve the Data of the First Node 1046
Retrieve the Data of the Last Node 1046
Begin and End 1046
Copy the List 1047
Destructor 1048
Copy Constructor 1048
Overloading the Assignment Operator 1049

Unordered Linked Lists 1049


Search the List 1050
Insert the First Node 1051
Insert the Last Node 1052
Header File of the Unordered Linked List 1057

Ordered Linked Lists 1058


Search the List 1059
Insert a Node 1060
Insert First and Insert Last 1064
xxii | C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Delete a Node 1065


Header File of the Ordered Linked List 1066

Print a Linked List in Reverse Order (Recursion Revisited) 1069


printList Reverse 1071

Doubly Linked Lists 1072


Default Constructor 1075
isEmptyList 1075
Destroy the List 1075
Initialize the List 1076
Length of the List 1076
Print the List 1076
Reverse Print the List 1076
Search the List 1077
First and Last Elements 1077

Circular Linked Lists 1083

Programming Example: Video Store 1084

Quick Review 1104

Exercises 1104

Programming Exercises 1109

STACKS AND QUEUES 1115


19 Stacks 1116
Stack Operations 1118

Implementation of Stacks as Arrays 1120


Initialize Stack 1123
Empty Stack 1124
Full Stack 1124
Push 1124
Return the Top Element 1126
Pop 1126
Copy Stack 1128
Constructor and Destructor 1128
Copy Constructor 1129
Table of Contents | xxiii

Overloading the Assignment Operator (=) 1129


Stack Header File 1130

Programming Example: Highest GPA 1134

Linked Implementation of Stacks 1138


Default Constructor 1141
Empty Stack and Full Stack 1141
Initialize Stack 1142
Push 1142
Return the Top Element 1144
Pop 1144
Copy Stack 1146
Constructors and Destructors 1147
Overloading the Assignment Operator (=) 1147
Stack as Derived from the
class unorderedLinkedList 1150

Application of Stacks: Postfix Expressions


Calculator 1151
Main Algorithm 1154
Function evaluateExpression 1154
Function evaluateOpr 1156
Function discardExp 1158
Function printResult 1158

Removing Recursion: Nonrecursive Algorithm


to Print a Linked List Backward 1161

Queues 1165
Queue Operations 1166
Implementation of Queues as Arrays 1168
Linked Implementation of Queues 1177
Queue Derived from the
class unorderedLinkedListType 1182

Application of Queues: Simulation 1183


Designing a Queuing System 1184
Customer 1185
Server 1188
xxiv | C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Server List 1191


Waiting Customers Queue 1196
Main Program 1198

Quick Review 1203

Exercises 1204

Programming Exercises 1210

APPENDIX A: RESERVED WORDS 1215

APPENDIX B: OPERATOR PRECEDENCE 1217

APPENDIX C: CHARACTER SETS 1219


ASCII (American Standard Code for
Information Interchange) 1219

EBCDIC (Extended Binary Coded


Decimal Interchange Code) 1220

APPENDIX D: OPERATOR OVERLOADING 1223

APPENDIX E: ADDITIONAL C++ TOPICS 1225


Binary (Base 2) Representation of a
Nonnegative Integer 1225
Converting a Base 10 Number to a
Binary Number (Base 2) 1225
Converting a Binary Number (Base 2) to Base 10 1227
Converting a Binary Number (Base 2) to Octal (Base 8)
and Hexadecimal (Base 16) 1228

More on File Input/Output 1230


Binary Files 1230
Random File Access 1236

Naming Conventions of Header Files in


ANSI/ISO Standard C++ and Standard C++ 1244
Table of Contents | xxv

APPENDIX F: HEADER FILES 1247


Header File cassert (assert.h) 1247

Header File cctype (ctype.h) 1248

Header File cfloat (float.h) 1249

Header File climits (limits.h) 1250

Header File cmath (math.h) 1252


Header File cstddef (stddef.h) 1253
Header File cstring (string.h) 1253

APPENDIX G: MEMORY SIZE ON A SYSTEM


AND RANDOM NUMBER GENERATOR 1257
Random Number Generator 1258

APPENDIX H: STANDARD TEMPLATE


LIBRARY (STL) 1259
Components of the STL 1259

Container Types 1260


Sequence Containers 1260
Sequence Container: Vectors 1260
Member Functions Common to All Containers 1269
Member Functions Common to Sequence Containers 1271
copy Algorithm 1272
Sequence Container: deque 1276
Sequence Container: list 1279

Iterators 1284
IOStream Iterators 1285
Container Adapters 1285

Algorithms 1289
STL Algorithm Classification 1289
STL Algorithms 1292
Functions fill and fill_n 1292
Functions find and find_if 1294
xxvi | C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Functions remove and replace 1295


Functions search, sort, and binary_search 1297

APPENDIX I: ANSWERS TO ODD-NUMBERED


EXERCISES 1301
Chapter 1 1301

Chapter 2 1304

Chapter 3 1306

Chapter 4 1307

Chapter 5 1309

Chapter 6 1311

Chapter 7 1312

Chapter 8 1313

Chapter 9 1314

Chapter 10 1316

Chapter 11 1317

Chapter 12 1318

Chapter 13 1321

Chapter 14 1322

Chapter 15 1323

Chapter 16 1324

Chapter 17 1325

Chapter 18 1326

Chapter 19 1327

INDEX 1331
P REFACE

WELCOME TO THE FIFTH EDITION OF C++ Programming: From Problem Analysis to Program
Design. Designed for a first Computer Science (CS1) C++ course, this text provides a
breath of fresh air to you and your students. The CS1 course serves as the cornerstone of
the Computer Science curriculum. My primary goal is to motivate and excite all CS1
students, regardless of their level. Motivation breeds excitement for learning. Motivation
and excitement are critical factors that lead to the success of the programming student. This
text is a culmination and development of my classroom notes throughout more than fifty
semesters of teaching successful programming to Computer Science students.

Warning: This text can be expected to create a serious reduction in the demand for
programming help during your office hours. Other side effects include significantly
diminished student dependency on others while learning to program.

C++ Programming: From Problem Analysis to Program Design started as a collection of brief
examples, exercises, and lengthy programming examples to supplement the books that were
in use at our university. It soon turned into a collection large enough to develop into a text.
The approach taken in this book is, in fact, driven by the students’ demand for clarity and readability.
The material was written and rewritten until the students felt comfortable with it. Most of the
examples in this book resulted from student interaction in the classroom.
As with any profession, practice is essential. Cooking students practice their recipes.
Budding violinists practice their scales. New programmers must practice solving
problems and writing code. This is not a C++ cookbook. We do not simply list the
C++ syntax followed by an example; we dissect the ‘‘why’’ behind all the concepts. The
crucial question of ‘‘why?’’ is answered for every topic when first introduced. This
technique offers a bridge to learning C++. Students must understand the ‘‘why?’’ in
order to be motivated to learn.
Traditionally, a C++ programming neophyte needed a working knowledge of another
programming language. This book assumes no prior programming experience. However,
some adequate mathematics background, such as college algebra, is required.
xxviii | C++ Programming: From Problem Analysis to Program Design, Fifth Edition

Changes in the Fifth Edition


The fifth edition contains more than 50 new programming exercises, and more than 150 new
exercises. Each of the Chapters 2 to 7 include a programming exercise which contains a
solution of a problem, however, the statements are in the incorrect order. So the student is
asked to rewrite the program with statements in the correct order. This will allow the students
to learn how to read and debug programs written by someone else. Another major change in
this edition is the inclusion of debugging sections in the chapters 2 to 7. In these sections, a
program with errors is included. The program is compiled and syntax errors, if any are shown.
We then show how to interpret the syntax errors and correct them. Some sections also show
how to find and correct logical errors. This edition also includes various new examples, such
as Examples 5-8, 7-8, 12-6, and 12-8. Various sections of Chapters 4, 5, 6, and 7 have been
rewritten. Chapter 8 includes additional string functions and virtual functions section of
Chapter 14 is rewritten with new examples.

Approach
The programming language C++, which evolved from C, is no longer considered an
industry-only language. Numerous colleges and universities use C++ for their first program-
ming language course. C++ is a combination of structured programming and object-oriented
programming, and this book addresses both types.
This book can be easily divided into two parts: structured programming and object-oriented
programming. The first 11 chapters form the structured programming part; Chapters 12
through 19 form the object-oriented part. However, only the first seven chapters are essential
to move on to the object-oriented portion.
In July 1998, ANSI/ISO Standard C++ was officially approved. This book focuses on ANSI/
ISO Standard C++. Even though the syntax of Standard C++ and ANSI/ISO Standard C++
is very similar, Chapter 8 discusses some of the features of ANSI/ISO Standard C++ that are
not available in Standard C++.
Chapter 1 briefly reviews the history of computers and programming languages. The reader can
quickly skim through this chapter and become familiar with some of the hardware components
and the software parts of the computer. This chapter contains a section on processing a C++
program. This chapter also describes structured and object-oriented programming.
Chapter 2 discusses the basic elements of C++. After completing this chapter, students
become familiar with the basics of C++ and are ready to write programs that are complicated
enough to do some computations. Input/output is fundamental to any programming
language. It is introduced early, in Chapter 3, and is covered in detail.
Chapters 4 and 5 introduce control structures to alter the sequential flow of execution.
Chapters 6 and 7 study user-defined functions. It is recommended that readers with no prior
programming background spend extra time on Chapters 6 and 7. Several examples are provided
to help readers understand the concepts of parameter passing and the scope of an identifier.
Preface | xxix

Chapter 8 discusses the user-defined simple data type (enumeration type), the namespace
mechanism of ANSI/ISO Standard C++, and the string type. The earlier versions of C did
not include the enumeration type. Enumeration types have very limited use; their main
purpose is to make the program readable. This book is organized such that readers can skip
the section on enumeration types during the first reading without experiencing any disconti-
nuity, and then later go through this section.
Chapter 9 discusses arrays in detail. Chapter 10 describes various searching and sorting
algorithms as well as an introduction to the vector class. Chapter 11 introduces records
(structs). The introduction of structs in this book is similar to C structs. This chapter is
optional; it is not a prerequisite for any of the remaining chapters.
Chapter 12 begins the study of object-oriented programming (OOP) and introduces classes.
The first half of this chapter shows how classes are defined and used in a program. The second
half of the chapter introduces abstract data types (ADTs). This chapter shows how classes in
C++ are a natural way to implement ADTs. Chapter 13 continues with the fundamentals of
object-oriented design (OOD) and OOP and discusses inheritance and composition. It
explains how classes in C++ provide a natural mechanism for OOD and how C++ supports
OOP. Chapter 13 also discusses how to find the objects in a given problem.
Chapter 14 studies pointers in detail. After introducing pointers and how to use them in a
program, this chapter highlights the peculiarities of classes with pointer data members and
how to avoid them. Moreover, this chapter also discusses how to create and work with
dynamic two-dimensional arrays. Chapter 14 also discusses abstract classes and a type of
polymorphism accomplished via virtual functions.
Chapter 15 continues the study of OOD and OOP. In particular, it studies polymorphism in C++.
The chapter specifically discusses two types of polymorphism—overloading and templates.
Chapter 16 discusses exception handling in detail. Chapter 17 introduces and discusses recur-
sion. Moreover, this is a standalone chapter, so it can be studied anytime after Chapter 10.
Chapters 18 and 19 are devoted to the study of data structures. Discussed in detail are linked
lists in Chapter 18 and stacks and queues in Chapter 19. The programming code developed in
these chapters is generic. These chapters effectively use the fundamentals of OOD.
Appendix A lists the reserved words in C++. Appendix B shows the precedence and
associativity of the C++ operators. Appendix C lists the ASCII (American Standard Code
for Information Interchange) and EBCDIC (Extended Binary Coded Decimal Interchange
Code) character sets. Appendix D lists the C++ operators that can be overloaded.
Appendix E has three objectives. First, we discuss how to convert a number from decimal to
binary and binary to decimal. We then discuss binary and random access files in detail.
Finally, we describe the naming conventions of the header files in both ANSI/ISO Standard
C++ and Standard C++. Appendix F discusses some of the most widely used library
routines, and includes the names of the standard C++ header files. The programs in
Appendix G show how to print the memory size for the built-in data types on your system
as well as how to use a random number generator. Appendix H gives an introduction to
xxx | C++ Programming: From Problem Analysis to Program Design, Fifth Edition

the Standard Template Library, and Appendix I provides the answers to odd-numbered
exercises in the book.

How to Use the Book


This book can be used in various ways. Figure 1 shows the dependency of the chapters.

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8 Chapter 9*

Chapter 10 Chapter 11 Chapter 12

Chapter 13 Chapter 14 Chapter 16

Chapter 15

Chapter 17

Chapter 18

Chapter 19

FIGURE 1 Chapter dependency diagram


Preface | xxxi

In Figure 1, dotted lines mean the preceding chapter is used in one of the sections of the
chapter and is not necessarily a prerequisite for the next chapter. For example, Chapter 9
covers arrays in detail. In Chapters 11 and 12, we show the relationship between arrays and
structs and arrays and classes, respectively. However, if Chapter 12 is studied before
Chapter 9, then the section dealing with arrays in Chapter 12 can be skipped without any
discontinuation. This particular section can be studied after studying chapter 9.
It is recommended that the first seven chapters be covered sequentially. After covering the
first seven chapters, if the reader is interested in learning OOD and OOP early, then Chapter
12 can be studied right after Chapter 7. Chapter 8 can be studied any time after Chapter 7.
After studying the first seven chapters in sequence, some of the approaches are:
1. Study chapters in the sequence: 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19.
2. Study chapters in the sequence: 9, 12, 14, 15, 13, 17, 18, 19, 10, 16.
3. Study chapters in the sequence: 12, 9, 10, 14, 15, 13, 17, 18, 19, 16.
4. Study chapters in the sequence: 12, 9, 14, 15, 13, 17, 18, 19, 10, 16.
FEATURES OF THE BOOK

Four-color
interior design
shows
accurate C++
code and
related
comments.
More than 300
visual diagrams,
both extensive
and exhaustive,
illustrate difficult
concepts.
Numbered examples
illustrate the key
concepts with their
relevant code. The
programming code
in these examples is
followed by a
Sample Run. An
explanation then
follows that
describes what each
line in the code
does.

Notes highlight important


facts about the concepts
introduced in the chapter.
Programming
Examples are
programs featured at
the end of each
chapter. Programming
Examples are where
everything in the
chapter comes
together. They are
highlighted with an
icon in the margin like
the one shown here.
These examples teach
problem solving skills
and include the
concrete stages of
input, output,
problem analysis and
algorithm design,
class design, and a
program listing All
programs are
designed to be
methodical,
consistent, and user-
friendly. Each
Programming
Example starts with a
problem analysis that
is followed by the
algorithm design and/
or class design. Every
step of the algorithm
is coded in C++. In
addition to helping
students learn
problem solving
techniques, these
detailed programs
show the student how
to implement concepts in an actual C++ program. We strongly recommend that students study the Programming
Examples carefully in order to learn C++ effectively. Students typically learn much from completely worked-out
programs. Further, programming examples reduce considerably the students’ need for help outside the classroom and
bolster the students’ self-confidence.
Exercises further
reinforce learning
and ensure that
students have, in
fact, mastered the
material.
Programming
Exercises challenge
students to write
C++ programs with
a specified
outcome.
S UPPLEMENTAL
R ESOURCES

The following supplemental materials are available when this book is used in a classroom
setting.
All instructor teaching tools are available with this book on a single CD-ROM.

Electronic Instructor’s Manual


The Instructor’s Manual that accompanies this textbook includes:
• Additional instructional material to assist in class preparation, including suggestions
for lecture topics.
• Solutions to all the end-of-chapter materials, including the Programming
Exercises.

ExamViewÒ
This textbook is accompanied by ExamView, a powerful testing software package that allows
instructors to create and administer printed, computer (LAN-based), and Internet exams.
ExamView includes hundreds of questions that correspond to the topics covered in this
text, enabling students to generate detailed study guides that include page references for
further review. These computer-based and Internet testing components allow students to
take exams at their computers, and save the instructor time because each exam is graded
automatically.

PowerPoint Presentations
This book comes with Microsoft PowerPoint slides for each chapter. These are included as a
teaching aid for classroom presentations, either to make available to students on the network
for chapter review, or to be printed for classroom distribution. Instructors can add their own
slides for additional topics that they introduce to the class.
Supplemental Resources | xxxix

Content for Online Learning


Course Technology has partnered with today’s leading distance learning solution providers
and class-management platforms. To access this material, visit www.cengage.com/webtutor
and search for your title. Instructor resources include the following: additional case projects,
sample syllabi, PowerPoint presentations, and more. For students to access this material, they
must have purchased a WebTutor PIN-code specific to this title and your campus platform.
The resources for students might include (based on instructor preferences): topic reviews,
review questions, practice tests, and more. For additional information, please contact your
sales representative.

Source Code
The source code, in ANSI/ISO Standard C++, is available at www.course.com, and is also
available on the Instructor Resources CD-ROM. The input files needed to run some of the
programs are also included with the source code.

Solution Files
The solution files for all Programming Exercises, in ANSI/ISO C++, are available at www.course.
com, and are also available on the Instructor Resources CD-ROM. The input files needed to run
some of the Programming Exercises are also included with the solution files.
A CKNOWLEDGEMENTS

There are many people that I must thank who, one way or another, contributed to the success
of this book. First, I would like to thank all the students who, during the preparation, were
spontaneous in telling me if certain portions needed to be reworded for better understanding
and clearer reading. Next, I would like to thank those who e-mailed numerous comments to
improve upon the second edition. I am thankful to Professors S.C. Cheng, Randall Crist, and
Vasant Raval for constantly supporting this project. I am also very grateful to the reviewers
who reviewed earlier versions of this book and offered many critical suggestions on how to
improve it.
I owe a great deal to the following reviewers who patiently read each page of every chapter of
the current version and made critical comments to improve on the book: Stefano Basagni,
Northeastern University; Jeff Ringenberg, University of Michigan; Colleen van Lent, Uni-
versity of Michigan; Tuan Vo, Mt. San Antonio College; Kerstin Voigt, California State
University San Bernardino; Lan Yang, Cal Poly Pomona. The reviewers will recognize that
their criticisms have not been overlooked and, in fact, made this a better book.
Next, I express thanks to Amy Jollymore, acquisition editor, for recognizing the importance
and uniqueness of this project. All this would not have been possible without the careful
planning of Senior Product Manager Alyssa Pratt. I extend my sincere thanks to Alyssa, as well
as to Content Project Manager, Mathew Hutchinson. I also thank Tintu Thomas of Integra
Software Services for assisting us in keeping the project on schedule. I would like to thank
Chris Scriver and Serge Palladino of QA department of Course Technology for patiently and
carefully proof reading the text, testing the code, and discovering typos and errors.
I am thankful to my parents for their blessings.
Finally, I am thankful for the support of my wife Sadhana and especially my daughter Shelly,
to whom this book is dedicated. She cheered me up whenever I was overwhelmed during the
writing of this book, and also made sure that the corrections were in place. Shelly always
draws special joy whenever I undertake such projects.
I welcome any comments concerning the text. Comments may be forwarded to the following
e-mail address: malik@creighton.edu
D. S. Malik
1
CHAPTER

A N O VERVIEW OF
COMPUTERS AND
P ROGRAMMING
L ANGUAGES
I N T H I S C H A P T E R , YO U W I L L :
. Learn about different types of computers
. Explore the hardware and software components of a computer system
. Learn about the language of a computer
. Learn about the evolution of programming languages
. Examine high-level programming languages
. Discover what a compiler is and what it does
. Examine a C++ program
. Explore how a C++ program is processed
. Learn what an algorithm is and explore problem-solving techniques
. Become aware of structured design and object-oriented design programming methodologies
. Become aware of Standard C++ and ANSI/ISO Standard C++
2 | Chapter 1: An Overview of Computers and Programming Languages

Introduction
Terms such as ‘‘the Internet,’’ which were unfamiliar just 20 years ago are now common.
Students in elementary school regularly ‘‘surf ’’ the Internet and use computers to design their
classroom projects. Many people use the Internet to look for information and to commu-
nicate with others. This is all made possible by the availability of different software, also
known as computer programs. Without software, a computer is useless. Software is devel-
oped by using programming languages. The programming language C++ is especially well
suited for developing software to accomplish specific tasks. Our main objective is to help you
learn how to write programs in the C++ programming language. Before you begin
programming, it is useful to understand some of the basic terminology and different
components of a computer. We begin with an overview of the history of computers.

A Brief Overview of the History of Computers


The first device known to carry out calculations was the abacus. The abacus was invented in
Asia but was used in ancient Babylon, China, and throughout Europe until the late middle
ages. The abacus uses a system of sliding beads in a rack for addition and subtraction. In 1642,
the French philosopher and mathematician Blaise Pascal invented the calculating device
called the Pascaline. It had eight movable dials on wheels and could calculate sums up to
eight figures long. Both the abacus and Pascaline could perform only addition and subtrac-
tion operations. Later in the 17th century, Gottfried von Leibniz invented a device that was
able to add, subtract, multiply, and divide. In 1819, Joseph Jacquard, a French weaver,
discovered that the weaving instructions for his looms could be stored on cards with holes
punched in them. While the cards moved through the loom in sequence, needles passed
through the holes and picked up threads of the correct color and texture. A weaver could
rearrange the cards and change the pattern being woven. In essence, the cards programmed a
loom to produce patterns in cloth. The weaving industry may seem to have little in common
with the computer industry. However, the idea of storing information by punching holes on
a card proved to be of great importance in the later development of computers.
In the early and mid-1800s, Charles Babbage, an English mathematician and physical
scientist, designed two calculating machines—the difference engine and the analytical
engine. The difference engine could perform complex operations such as squaring
numbers automatically. Babbage built a prototype of the difference engine, but the actual
device was never produced. The analytical engine’s design included input device, data
storage, a control unit that allowed processing instructions in any sequence, and output
devices. However, the designs remained in blueprint stage. Most of Babbage’s work is
known through the writings of his colleague Ada Augusta, Countess of Lovelace. Augusta
is considered the first computer programmer.
At the end of the 19th century, U.S. Census officials needed help in accurately tabulating
the census data. Herman Hollerith invented a calculating machine that ran on electricity
and used punched cards to store data. Hollerith’s machine was immensely successful.
Hollerith founded the Tabulating Machine Company, which later became the computer
and technology corporation known as IBM.
Elements of a Computer System | 3

The first computer-like machine was the Mark I. It was built, in 1944, jointly by IBM and
Harvard University under the leadership of Howard Aiken. Punched cards were used to feed 1
data into the machine. The Mark I was 52 feet long, weighed 50 tons, and had 750,000 parts.
In 1946, the ENIAC (Electronic Numerical Integrator and Calculator) was built at the
University of Pennsylvania. It contained 18,000 vacuum tubes and weighed some 30 tons.
The computers that we know today use the design rules given by John von Neumann in
the late 1940s. His design included components such as an arithmetic logic unit, a control
unit, memory, and input/output devices. These components are described in the next
section. Von Neumann’s computer design makes it possible to store the programming
instructions and the data in the same memory space. In 1951, the UNIVAC (Universal
Automatic Computer) was built and sold to the U.S. Census Bureau.
In 1956, the invention of transistors resulted in smaller, faster, more reliable, and more
energy-efficient computers. This era also saw the emergence of the software development
industry, with the introduction of FORTRAN and COBOL, two early programming
languages. In the next major technological advancement, transistors were replaced by tiny
integrated circuits, or ‘‘chips.’’ Chips are smaller and cheaper than transistors and can contain
thousands of circuits on a single chip. They give computers tremendous processing speed.
In 1970, the microprocessor, an entire CPU on a single chip, was invented. In 1977,
Stephen Wozniak and Steven Jobs designed and built the first Apple computer in their
garage. In 1981, IBM introduced its personal computer (PC). In the 1980s, clones of the
IBM PC made the personal computer even more affordable. By the mid-1990s, people
from many walks of life were able to afford them. Computers continue to become faster
and less expensive as technology advances.
Modern-day computers are powerful, reliable, and easy to use. They can accept spoken-word
instructions and imitate human reasoning through artificial intelligence. Expert systems assist
doctors in making diagnoses. Mobile computing applications are growing significantly. Using
handheld devices, delivery drivers can access global positioning satellites (GPS) to verify
customer locations for pickups and deliveries. Cell phones permit you to check your e-mail,
make airline reservations, see how stocks are performing, and access your bank accounts.
Although there are several categories of computers, such as mainframe, midsize, and
micro, all computers share some basic elements, described in the next section.

Elements of a Computer System


A computer is an electronic device capable of performing commands. The basic commands
that a computer performs are input (get data), output (display result), storage, and perfor-
mance of arithmetic and logical operations.
In today’s market, personal computers are sold with descriptions such as a Pentium 4
Processor 2.80 GHz, 1 GB RAM, 250 GB HD, VX750 19" Silver Flat CRT Color
Monitor, preloaded with software such as an operating system, games, encyclopedias, and
application software such as word processors or money management programs. These
descriptions represent two categories: hardware and software. Items such as ‘‘Pentium 4
4 | Chapter 1: An Overview of Computers and Programming Languages

Processor 2.80 GHz, 1GB RAM, 250 GB HD, VX750 19" Silver Flat CRT Color Monitor’’
fall into the hardware category; items such as ‘‘operating system, games, encyclopedias, and
application software’’ fall into the software category. Let’s consider the hardware first.

Hardware
Major hardware components include the central processing unit (CPU); main memory
(MM), also called random access memory (RAM); input/output devices; and secondary
storage. Some examples of input devices are the keyboard, mouse, and secondary storage.
Examples of output devices are the screen, printer, and secondary storage. Let’s look at
each of these components in greater detail.

Central Processing Unit and Main Memory


The central processing unit is the ‘‘brain’’ of the computer and the single most expensive
piece of hardware in a computer. The more powerful the CPU, the faster the computer.
Arithmetic and logical operations are carried out inside the CPU. Figure 1-1(a) shows some
hardware components.

. .
Input . .
Central . .
Device
Processing 1000 54
Unit (CPU) 1001
Output A
. .
Device . .
. .
Main Memory 2000
2001
. .
. .
. .
Secondary Storage Main Memory

(a) (b)

FIGURE 1-1 Hardware components of a computer and main memory

Main memory, or random access memory, is connected directly to the CPU. All
programs must be loaded into main memory before they can be executed. Similarly, all
data must be brought into main memory before a program can manipulate it. When the
computer is turned off, everything in main memory is lost.
Main memory is an ordered sequence of cells, called memory cells. Each cell has a unique
location in main memory, called the address of the cell. These addresses help you access
the information stored in the cell. Figure 1-1(b) shows main memory with some data.
Another Random Document on
Scribd Without Any Related Topics
about three months after the seventh-month movement, when
Adventists had taken time to review the past, and settle, as was
supposed, upon a firm, united position.
“It produced everywhere the most deep searching of heart and
humiliation of soul before the God of high Heaven. It caused a
weaning of affections from the things of this world, a healing of the
controversies and animosities, a confession of wrongs, a breaking
down before God, and penitent, broken-hearted supplications to him
for pardon and acceptance. It caused self-abasement and prostration
of soul, such as we never before witnessed. As God, by Joel,
commanded, when the great day of God should be at hand, it
produced a rending of hearts and not of garments, and a turning
unto the Lord with fasting, and weeping, and mourning. As God said
by Zechariah, a spirit of grace and supplication was poured out upon
his children; they looked to him whom they had pierced, there was a
great mourning in the land, every family apart and their wives apart,
and those who were looking for the Lord afflicted their souls before
him. Such was its effect upon the children of God.
“While none could deny the possibility of the Lord’s then coming,
and as the fulfillment of some of the types chronologically at Christ’s
first advent rendered it highly probable that those which typified the
second advent, would also be chronologically fulfilled, so general an
awakening, and with such blessed fruits, could not but impress many
minds; and those who were not convinced of the soundness of the
typical argument, were led to regard it as a fulfillment of the parable
of the ten virgins, in the twenty-fifth of Matthew,—as their arising to
trim their lamps, after having gone forth to meet the Bridegroom,
and slumbering while he tarried; so that the definite time was finally
embraced by nearly all of the Advent faith. So universal a movement
among those who a short time before were comparatively asleep on
this question, could not be unnoticed by the world.
“The wicked, consequently, flocked to the various places of meeting,
some out of idle curiosity to hear, others out of concern for their
spiritual interests, and others still to scoff at solemn things. Those
who believed they should so shortly stand in their Saviour’s
presence, and whose works corresponded with their faith, could not
but feel a nearness of access to God, and sweet communion with
him; and the souls of such were greatly blessed. With a realizing
sense of such a nearness of the greatest of all events, as we came
up to that point of time, all other unnecessary cares were laid aside,
and the whole soul was devoted to a preparation for the great event.
God being more ready to give than we are to receive, does not
permit any thus to plead in vain; and his Holy Spirit came down like
copious showers upon the parched earth. It was then evident that
there was faith upon the earth, such faith as is ever ready to act in
accordance with what the soul believes that God has spoken; such
faith as would, in obedience to a supposed command, bid all the
pleasures of this world adieu, having respect to the recompense of
reward. Such was a faith like that of Abraham’s when, at the
command of God, he went out, ‘not knowing whither he went,’ nor
withheld his only son; and here were those all ready to join the
multitude, who through faith will inherit the promises.”
THE PASSING OF THE TIME.
The tenth day of the seventh month of the Jewish year 1844, came
and passed, and left impressions upon the minds of believers not
easily effaced; and although a quarter of a century has passed since
that memorable period, yet that work has not lost its interest and
force upon the minds of those who participated in it. Even now,
when one who shared in that blessed work, and who feels its
hallowed influence rekindling upon his mind—if in obedience to the
injunction of the apostle when he says, “Call to remembrance the
former days in which, after ye were illuminated, ye endured a great
fight of afflictions, partly whilst ye were made a gazing stock, both
by reproaches and afflictions, and partly whilst ye became
companions of them that were so used”—shall speak of that solemn
work, of that consecration of all, made in full view of eternal scenes,
and of that sweet peace and holy joy which filled the minds of the
waiting ones, his words will not fail to touch the feelings of all who
shared the blessings of that work and have held fast.
And those who participated in that movement are not the only ones
who can now go back in their experience, and feast upon the faith-
reviving, soul-inspiring realities of the past. Those who have since
embraced the Advent faith and hope, and who have seen in the
three messages, of Revelation xiv, the past consecration and
blessedness, the present work of preparation, and the future glory,
may go back with us to the autumn of 1844, and with us share the
rekindling of the heavenly illumination. Was that our Jerusalem,
where we waited for, and enjoyed, the outpouring of the Holy Spirit?
Then as all Christians, as well as Christ’s first disciples who were
present on the occasion, have looked back to the day of Pentecost
with pleasure and profit, so may these who have embraced the
doctrine of the Second Advent since the memorable seventh-month
movement, look back to that period with all that interest those can
who participated in it.
The impressions made and left upon the minds of believers were
deep and lasting. However far one has since departed from God and
his truth, there still remains upon the soul of the apostate traces of
the work. Let him hear the subject afresh; let the simple facts be
again brought before his mind, and he will feel upon this subject as
he can feel upon no other. And those who took part in that work,
who are far backslidden from God, yet cherish regard for the word of
God and Christian experience, will yet feel deeply over this subject,
and the faith of many of them will be resurrected to new life. God
grant that these pages may prove a blessing to many such.
The disappointment at the passing of the time was a bitter one. True
believers had given up all for Christ, and had shared his presence as
never before. They had, as they supposed, given their last warning
to the world, and had separated themselves, more or less, from the
unbelieving, scoffing multitude. And with the divine blessing upon
them, they felt more like associating with their soon-expected
Master and the holy angels, than with those from whom they had
separated themselves. The love of Jesus filled every soul, and
beamed from every face, and with inexpressible desires they prayed,
“Come Lord Jesus, and come quickly.” But he did not come. And now
to turn again to the cares, perplexities, and dangers of life, in full
view of the jeers and revilings of unbelievers who now scoffed as
never before, was a terrible trial of faith and patience. When Elder
Himes visited Portland, Me., a few days after the passing of the time,
and stated that the brethren should prepare for another cold winter,
my feelings were almost uncontrollable. I left the place of meeting
and wept like a child.
But God did not forsake his people. His Spirit upon them still abode,
with all who did not rashly deny and denounce the good work in the
Advent movement up to that time. And with especial force and
comfort did such passages as the following, to the Hebrews, come
home to the minds and hearts of the tried, waiting ones: “Cast not
away therefore your confidence, which hath great recompense of
reward. For ye have need of patience, that, after ye have done the
will of God, ye might receive the promise. For yet a little while, and
He that shall come will come, and will not tarry. Now the just shall
live by faith; but if any man draw back, my soul shall have no
pleasure in him. But we are not of them who draw back unto
perdition; but of them that believe to the saving of the soul.” Chap.
x, 35-39. The points of interest in this portion of Scripture are—
1. Those addressed are in danger of casting away their confidence in
that in which they had done right.
2. They had done the will of God, and were brought into that state
of trial where patience was necessary.
3. The just at this time are to live by faith, not by doubting whether
they had done the will of God, but faith, in that in which they had
done the will of God.
4. Those who should not endure the trial of faith, but should cast
away their confidence in the work in which they did the will of God,
and draw back, would take the direct road to perdition.
But why apply all this to the subject of the second advent? Answer:
Because Paul applies it there. His words, in the very center of the
foregoing quotation from his epistle to the Hebrews, forbid any other
application: “For yet a little while, and he that shall come will come,
and will not tarry.” No one will for a moment question that the
second advent is the subject upon which the apostle treats. The
peculiar situation of those who should be looking for the second
appearing of Jesus, is the burden of his exhortation. And how
wonderfully applicable to those who were sadly disappointed,
tempted and tried, in the autumn of 1844, are his words. With great
confidence had they proclaimed the coming of the Lord, with the
assurance that they were doing the will of God. But as the time
passed, they were brought into a position exceedingly trying to faith
and patience. Hence the words of Paul to them, just then, and just
there. “Cast not away therefore your confidence ... Ye have need of
patience.... Ye have done the will of God.” To this decision of the
apostle every true Adventist, who tasted the good word of God and
the powers of the world to come, in the movement of 1844, will
respond, Amen.
But how fearful the words which follow: “Now the just shall live by
faith; but if any man draw back my soul shall have no pleasure in
him.” As Adventists came up to the point of expectation in the
blazing light of unsealed prophecy, and the rapidly-fulfilling signs
that Christ’s coming was at the doors, they walked, as it were, by
sight. But now they stand with disappointed hopes, and stricken
hearts, and live by faith in the sure word, and the work of God in
their Second-Advent experience. With these who hold fast, God is
well pleased; but in those who draw back he has no pleasure. These
believe to the saving of the soul; while those who become impatient,
cast away their confidence in the way God has led them, and give it
up as the work of man, or of Satan, and draw back to perdition.
This and many other portions of Scripture of like import, having a
direct application to the condition of believers at that time, served
not only as an encouragement to them to hold fast their faith, but as
a warning to them not to apostatize. And a general impression
remained upon the minds of believers for some time after the
disappointment, that the seventh-month movement was in the direct
providence of God, and that those who had been engaged in this
work had done his will.
And according to the best light they then had, there was a general
agreement that the seventh-month movement was the last great
test, that the harvest of the earth was ripe for the sickle of the Son
of man, and that the door was shut. That the salvation of the soul,
or perdition, hung upon the manner in which those who heard
treated that solemn message, I doubt not. And this is especially
clear in the case of the disappointed believers after the time passed.
In holding fast and believing, there was salvation; in drawing back,
the result would be perdition. The view, however, that the harvest of
the earth was ripe, and that the door was shut, was soon
abandoned. But although all, long since, gave up this position as
incorrect, I fail to see why they should be censured for taking it
upon the passing of the time. In fact, the conclusion seems very
natural, and I hardly see how they could have come to any other. I
will here mention some of the reasons why such a conclusion was
reasonable, if not unavoidable.
1. William Miller and others had taught that the door would be shut,
and that probation would close a short time before the second
advent. In a letter to Elder J. V. Himes, October 6, 1844, he said: “I
am strong in the opinion that the next will be the last Lord’s day
sinners will ever have in probation. And within ten or fifteen days
from thence, they will see Him whom they have hated and despised,
to their shame and everlasting contempt.”
2. And, certainly, that probation will close prior to the second advent
is plainly taught in the following emphatic testimony from Rev. xxii,
11, 12: “He that is unjust, let him be unjust still; and he which is
filthy, let him be filthy still; and he that is righteous, let him be
righteous still; and he that is holy, let him be holy still. And behold I
come quickly.” I will only add, that the order of events here given is,
first, the final decision of all men living at the close of probation,
and, second, then follows the advent of Him who says, “And behold
I come quickly.”
3. All true believers expected that probation would close as soon as
the tenth day of the seventh month. And as the time of expectation
drew near, their burdened spirits felt more and still more heavily the
weight and responsibility of doing every duty to others. But as the
point of expectation was finally reached, all this burden at once fell
off. This was as true of the isolated brother or sister, in some distant
part of the country, as with those in the crowded city mingling with
hundreds of like faith. It was true of all. All felt that their work in
warning sinners was done. No one can have a just idea of this great
change, only those who participated in the movement, and came up
to the time of expectation with the burden of the solemn work upon
them. Jesus had not come as they expected, and why this great
change had come over all was a matter of proper inquiry. And how
natural the conclusion, to say the least, that probation was ended.
4. The change that had suddenly come over the ungodly seemed to
strengthen the conviction that the door was shut. Although the
passing of the time, removing their fears, may now be regarded as a
sufficient cause for the change in them, yet at that time the fiend-
like conduct of many after the tenth day passed, who but a few
hours or days before had appeared penitent, gave the idea that the
restraining influence of the Spirit of God had forever left them.
In view of these things it should not be a matter of surprise to any,
that Adventists were agreed that the midnight cry was the last great
test, that the work for the world was finished, and that the door was
shut. That this was their faith, may be seen by reviewing the
writings of leading men in the cause, published immediately after
the passing of the time.
William Miller, in a letter addressed to J. V. Himes, says:
“We have done our work in warning sinners, and in trying to awaken
a formal church. God, in his providence, has shut the door; we can
only stir one another up to be patient; and be diligent to make our
calling and election sure. We are now living in the time specified by
Malachi iii, 18; also Dan. xii, 10; Rev. xxii, 10-12. In this passage we
cannot help but see that a little while before Christ should come,
there would be a separation between the just and unjust, the
righteous and wicked, between those who love his appearing and
those who hate it. And never, since the days of the apostles, has
there been such a division line drawn as was drawn about the tenth
day of the seventh Jewish month. Since that time they say ‘they
have no confidence in us.’ We have now need of patience, after we
have done the will of God, that we may receive the promise.”
The Advent Herald, for November 13, 1844, J. V. Himes, S. Bliss, and
A. Hale, editors, says:
“But the alarm was everywhere made; the cry was everywhere
given. And again we can see that God was with us. It was a soul-
purifying work; and the children of God bowed themselves in his
presence and received blessings to their souls, unprecedented in the
history of the Advent cause. And yet we are disappointed; the day
passed away and we are still here. And those who only looked on,
and passed by, were ready to exclaim that it was all a delusion; and
that now of a certainty we must relinquish all our hopes, and
abandon all our expectations. We, however, do not thus feel. As
great a paradox as it may be to our opponents, yet we can discern in
it the leadings of God’s providence; and when we are reviled and
censured by those to whom the world look as the Gamaliels of our
age, we feel that they are only speaking evil of the things they
understand not.
“Those who have not been in this late movement, can appreciate
nothing respecting it. And we regard it as another, and a more
searching test, than the first proclamation of the time. It has
searched Jerusalem as with candles; and it has purged out the old
leaven. It has tested the hearts of all who heard it, and awakened a
love for the Lord’s appearing; or it has called forth a hatred, more or
less perceivable, but known to God, of his coming. It has drawn a
line, and awakened sensibilities, so that those who will examine their
own hearts, may know on which side of it they would have been
found, had the Lord then come; whether they would have
exclaimed, ‘Lo! this is our God, we have waited for him and he will
save us;’ or whether they would have called to rocks and mountains
to fall on them to hide them from the face of Him that sitteth on the
throne, and from the wrath of the Lamb. God thus, as we believe,
has tested his people, has tried their faith, has proved them, and
seen whether they would shrink, in the hour of trial, from the
position in which He might see fit to place them; and whether they
would relinquish this world and rely with implicit confidence in the
work of God.
“And we as much believe that we have done the will of God in thus
sounding the alarm, as we believe that Jonah did when he entered
into Nineveh a day’s journey, and cried, saying, ‘Yet forty days and
Nineveh shall be overthrown.’ Nineveh was not then overthrown; nor
has the Lord yet wrought deliverance in the earth, nor the
inhabitants of the world fallen. Was Jonah a false prophet when he
preached the time of Nineveh’s destruction? No; he had only
preached the preaching that God had bid him. But God had said that
‘at what instant I shall speak concerning a nation and concerning a
kingdom to pluck up and to pull down and to destroy it; if that
nation against whom I have pronounced, turn from their evil, I will
repent of the evil that I thought to do unto them.’ Jer. xviii, 7, 8. ‘So,
the people of Nineveh believed God and proclaimed a fast, and put
on sackcloth, from the greatest of them even to the least of them;
and God saw their works that they turned from their evil way; and
God repented of the evil that he said he would do unto them; and
he did it not.’ The preaching of Jonah served as a test to the
inhabitants of Nineveh, and accomplished God’s purposes, as much
as it would have done had the city perished.
“So we believe that this last cry has been a test; and that with our
views of duty, we should as much have sinned against God, had we
refrained from giving that message, as Jonah did when ‘he rose up
to flee unto Tarshish from the presence of the Lord;’ that we should
as much have sinned, had we refused to give heed to it, as the
Ninevites would in refusing to repent at his preaching; and that all
who are angry that we have preached a time which has not been
realized, are as guilty as Jonah was when he was angry and prayed
the Lord to take his life from him, because God had spared that
great city.”
The following is from the Advent Herald of October 30, 1844, relative
to the suspension of meetings in the Advent Tabernacle of Boston.
The article from which it is taken, had previously been inserted in
several of the daily papers of that city. It is important, as it correctly
sets forth the views and feelings of Adventists at that time. In view
of such testimony, it is vain for any man to deny that it was the
universal belief of Adventists, in the autumn of 1844, that their work
for the world was forever done. After giving some of the reasons
why they expected the Lord on the tenth day of the seventh month,
the writer of the article says:
“With this expectation we were desirous to meet once more, to
mingle our prayers, and to encourage one another in the last work
of preparation; and for this purpose we had met at our well-known
place of worship in this city. We gave no special notice of our
meeting, we made no appeal to the public, and it was characterized
by no exercises which were calculated to excite either the mirth or
vengeance of any portion of the community.
“We were serious, we were bowed in penitence and prayer before
God, or heartily affected by the mutual confessions of tried and dear
friends. We had no ill-feeling to indulge toward any man; we felt
that we were done with the world, and had forgiven them the many
injuries they had inflicted upon us; but stale and silly slanders in
reference to us were revived; the restless spirits of the community
have been aroused; we could not meet in peace, and our meetings
in consequence have been suspended. And we now make these
remarks to disabuse the public, and with the hope that some, who
would not otherwise give their attention to the calls of the present
time, may lay them to heart.
“To the city authorities, who faithfully rendered their services, we are
grateful, though we could not promote the objects of the meeting
when such protection was needed.
“We forgive our enemies. They have not injured us; and oh! that
they could see how much they may have injured themselves; but we
have done with them now. We expect the realization of the promise
of God. He who delivered Noah and Lot; he who brought his people
out of Egypt and Babylon, has promised (as we believe) to save
them finally ‘by his Son from Heaven.’ We expect it. We have
hazarded all on that expectation; and we only ask that God may give
us, and all who look for him, grace to abide the issue.
“In behalf of the Adventists in Boston and vicinity,
“Joshua V. Himes.”
I have not a word of censure for a single soul who came to the
honest conclusion that the work of warning sinners closed with the
burden of the midnight cry. And more, I solemnly believe that the
providence of God brought us to that position. And there the Advent
hosts should have remained, patiently waiting, watching and
praying, until our true position could have been clearly seen by the
light of the heavenly sanctuary.
ARGUMENT FROM THE TYPES.
In the providence of God, in the seventh-month movement the
attention of the people was turned to the types of the law of Moses.
The argument which had been given, that as the vernal types,
namely, the passover, the wave sheaf, and the meat-offering, were
fulfilled in their order and time in the crucifixion, the resurrection of
Christ, and the descent of the Holy Spirit on the day of Pentecost, so
would the autumnal types be fulfilled as to time, in the events
connected with the second advent, seemed to be conclusive and
satisfactory. The position taken was, that as the high priest came out
of the typical sanctuary on the tenth day of the seventh month and
blessed the people, so Christ, our great High Priest, would on that
day come out of Heaven to bless his waiting people.
But it should be borne in mind that at that time those types which
point to the work in the heavenly sanctuary were not understood. In
fact, no one had any definite idea of the tabernacle of God in
Heaven. We now see that the two holies of the typical sanctuary,
made by the direction of the Lord to Moses, with their two distinct
ministrations—the daily and the yearly services,—were, in the
language of Paul to the Hebrews, “patterns of things in the
Heavens,” “figures of the true,” chapter ix. He also says of the work
of the Jewish priests in chapter viii, “Who serve unto the example
and shadow of heavenly things.” His words mean simply this: In
Heaven there is a sanctuary where Christ ministers, and that
sanctuary has two holies, and two distinct ministrations, as truly as
the earthly sanctuary had. If his words do not mean this, they have
no meaning at all. How natural, then, the conclusion, that as the
Jewish priests ministered daily in connection with the holy place of
the sanctuary, and on the tenth day of the seventh month, at the
close of their yearly round of service, the high priest entered the
most holy place to make atonement for the cleansing of the
sanctuary, so Christ ministered in connection with the holy place of
the heavenly sanctuary from the time of his ascension to the ending
of the 2300 days of Dan. viii, in 1844, when on the tenth day of the
seventh month of that year he entered the most holy place of the
heavenly tabernacle to make a special atonement for the blotting out
of the sins of his people, or, which is the same thing, for the
cleansing of the sanctuary. “Unto two thousand three hundred days,”
said the angel to the prophet, “then shall the sanctuary be
cleansed.”
The typical sanctuary was cleansed from the sins of the people with
the offering of blood. The nature of the cleansing of the heavenly
sanctuary may be learned from the type. By virtue of his own blood,
Christ entered the most holy to make a special atonement for the
cleansing of the heavenly tabernacle. For clear and full expositions of
the sanctuary and the nature of its cleansing, see works upon the
subject by J. N. Andrews and U. Smith, for sale at the Review Office,
Battle Creek, Mich.
With this view of the heavenly sanctuary before the reader, he can
see the defect in the seventh-month theory. It now appears evident
that the conclusion that Christ would come out of Heaven on that
day is not justified by the premises in the case. But if Christ’s
ministry in the heavenly sanctuary was to last but one year, on the
last day of which he would make an atonement for the cleansing of
the heavenly tabernacle, according to the type, then the conclusion
that he would on that day come out and bless his waiting people,
would be irresistible.
But let it be remembered that “the law having a shadow of good
things to come,” was “not the very image of the things.” In the
shadow, the round of service, first in the holy place for the entire
year, save one day, and second, in the most holy place on the last
day of that year, was repeated each successive year. But not so in
the ministry of Christ. He entered the holy place of that heavenly
sanctuary at his ascension once for all. There he ministered till the
time for the cleansing of the sanctuary at the close of the 2300 days
in the autumn of 1844. To accomplish this work, he then entered the
most holy place once for all. Christ suffered upon the cross—not
often—but once for all. He entered upon his work in the holy place
once for all. And he cleanses the heavenly sanctuary for the sins of
his people once for all. His ministry in the holy, from his ascension in
the spring of A. D. 31 to the autumn of 1844, was eighteen hundred
and thirteen years and six months. The period of his ministry in the
most holy can no more be defined before its close, than the time of
his ministry in the holy could be defined before it terminated.
Therefore, however much the tenth-day atonement for the cleansing
of the typical sanctuary proved that our great High Priest would
enter the most holy of the heavenly tabernacle on the tenth day of
the seventh month, it proved nothing to the point that he would on
that day come out of the most holy place.
But just what was accomplished on the tenth day of the seventh
month became a matter of discussion. Some took the rash position
that the movement had not been directed by the providence of God.
They cast away their confidence in that work, not having sufficient
faith and patience to “wait” and “watch,” until it should be explained
by the light of the sanctuary and the three messages of Rev. xiv, and
they drew back, to say the least, toward perdition.
Others trembled for this fearful step, and felt the deepest solicitude
for the welfare of the flock, and exhorted the brethren to patiently
wait and watch for the coming of the Lord, in full faith that God had
been in the work. Among these was William Miller. In a letter
published in the Advent Herald for Dec. 11, 1844, he says:
“Dear Bro. Himes: Be patient, establish your heart, for the coming of
the Lord draweth nigh. For ye have need of patience, that after ye
have done the will of God, ye might receive the promise. For yet a
little while and he that shall come will come, and will not tarry.”
The following is from the cheering pen of Eld. F. G. Brown, who was
not only a man of ability, but one who drank deeply at the fountain
of advent experience. He saw and felt the danger of drawing back,
and wrote the following letter to encourage his brethren to hold fast
and believe to the saving of the soul. It was written Nov. 11, 1844,
and published in the Advent Herald.
“Dear Brethren and Sisters: The great God has dealt wonderfully with
us. When we were in a state of alarming blindness in relation to the
coming of the great and terrible day of the Lord, he saw fit to
awaken us from our death-like slumbers, to a knowledge of these
things. How little of our own or man’s agency was employed in this
work, you know. Our prejudices, education, tastes, both intellectual
and moral, were all opposed to the doctrine of the Lord’s coming.
We know that it was the Almighty’s arm that disposed us to receive
this grace. The Holy Ghost wrought it in our inmost souls, yea,
incorporated it into our very being, so that it is now a part of us, and
no man can take it from us. It is our hope, our joy, our all. The Bible
reads it, every page is full of the Lord’s immediate coming, and
much from without strengthens us in the belief that the Judge
standeth at the door! At present everything tries us. Well, we have
heretofore had almost uninterrupted peace and exceeding great joy.
True, we have had some trials formerly, but what were they in
comparison with the glory to be revealed? We are permitted to live
in the days of the Son of man, which Jesus spake of as a desirable
day. How special the honor! How unspeakable the privilege!
“And shall we be so selfish as not to be willing to endure a little trial
for such a day, when all our worthy and honored predecessors have
so patiently submitted to the toils and sufferings incident to their
pilgrimage and to their times? Let it never be! We know that God
has been with us. Perhaps never before this has he for a moment
seemed to depart from us. Shall we now begin like the children of
Israel to doubt, and to fear, and repine, after he has so frequently
and signally shown us his hand in effecting for us one deliverance
after another? Has God blessed us with sanctification, and salvation,
and glory, now to rebuke and destroy us? The thought is almost
blasphemous. Away with it! Have we been so long with our Lord and
yet not know him? Have we read our Bibles in vain? Have we
forgotten the record of his wonderful dealings unto his people in all
past ages? Let us pause, and wait, and read, and pray, before we
act rashly or pronounce a hasty judgment upon the ways and works
of God. If we are in darkness, and see not as clearly as heretofore,
let us not be impatient. We shall have light just as soon as God sees
it will be for our good. Mark it, dearly beloved, our great Joshua will
surely bring us unto the goodly land. I have no kind of fears of it,
and I will not desert him before he does me.
“He is doing the work just right. Glory to his name! Remember, you
have been sailing a long, long voyage, and you began to think
yourselves pretty skillful sailors until you approached the home
coast, when the Pilot coming on board, you had to relinquish the
charge to him, and oh! how hard it is to commit all your precious
cargo and your noble vessel into his hands. You fear, you tremble,
lest the gallant ship should become a wreck, and the dearly-bought
freight be emptied into the ocean! But don’t fear. Throw off the
master, and like a good, social, relieved officer, go and take your
place with the humble, yet sturdy crew, and talk over home scenes
and endearments. Cheer up, ‘all’s well.’
“You have finished your work, and now be patient, and you shall
have the reward.
“It was necessary that our ‘faith’ and ‘patience’ should be tried
before our work could be completed. We closed up our work with
the world some time ago. This is my conviction. And now God has
given us a little season of self-preparation, to prove us before the
world. Who now will abide the test? Who is resolved to see the end
of his faith, live or die? Who will go to Heaven if he has to go alone?
Who will fight the battle through, though the armor-bearers faint,
and fear, and fail? Who will keep his eye alone on the floating flag of
his King, and, if need be, sacrifice his last drop of blood for it? Such
only are worthy to be crowned, and such only will reap the glorious
laurels.
“We must be in speaking distance of port. God’s recent work for us
proves it. We needed just such a work if Christ is coming forthwith. I
bless God for such glorious manifestations of himself to his people.
Don’t dishonor him, questioning whether it might not have been the
work of man, for he will vindicate that, and his word, too, very
shortly, is my solemn belief. Do not be allured by the baits that may
be flung out to draw you back from your confidence in God. The
world and the nominal church know nothing at all of your hope.
They cannot be made to understand us. Let them alone. You have
buried your name and reputation once, and now do not go to
digging it up again, when all manner of evil is spoken of you, falsely,
for Christ’s sake. Pray for your enemies. Do look straight ahead, lest
your minds again become occupied with earth—its business, cares,
labors, pleasures, friends. The Bible, the Bible, is the best teacher
now. Prayer, prayer, is the best helper. The next signal we have will
be the final one. Oh! shall any of us be found with our lamps going
out when the Master comes? Oh! how impressive the Saviour’s
repeated admonition, Watch, watch, watch.”
Many concluded that great changes took place on the tenth day of
the seventh month, closely connected with the final destiny of men,
but as yet there was no well-defined position as to what did take
place.
Joseph Marsh, editor of the Voice of Truth, Nov. 7, 1844, says:
“We did believe that he would come at that time; and now, though
we sorrow on account of our disappointment, yet we rejoice that we
have acted according to our faith. We have had, and still have, a
conscience void of offense in this matter, toward God and man. God
has blessed us abundantly, and we have not a doubt but that all will
soon be made to work together for the good of his dear people, and
his glory.
“We cheerfully admit that we have been mistaken in the nature of
the event we expected would occur on the tenth day of the seventh
month; but we cannot yet admit that our great High Priest did not
on that very day accomplish all that the type would justify us to
expect. We now believe he did.”
Where are we in the fulfillment of prophecy? soon became a matter
of most interesting inquiry. Some yielded to the clamors of the
church and world, who called for confessions that they had been
mistaken at least in the time, and among this number were several
able ministers. Their fearful course greatly increased the anxiety to
understand the real position. The hour was a most trying one. There
seemed to be a strong inclination with many to draw back, which
ripened in them into a general stampede in the direction of Egypt.
Finally, not a few settled, with more or less clearness, upon a
position embracing the following points:
1. That the parable of the ten virgins represented the great Advent
movement, each specification illustrating a corresponding event
connected with Second-Advent history.
2. That, in answer to the inquiry, Where are we? the point of time
was reached, when the words of our Lord following the parable were
applicable, “Watch, therefore, for ye know neither the day nor the
hour wherein the Son of man cometh.” Matt. xxv, 13.
3. That the time had come to liken, or to compare, the experience of
those who were looking for the kingdom, here called the kingdom of
Heaven, with an eastern marriage, and that in order to do this, both
must be matters of history, showing that each specification in the
parable was already fulfilled.
4. That the time when to compare Second-Advent experience with
the events in the marriage was definitely pointed out by our Lord
when he says, “Then shall the kingdom of Heaven be likened unto
ten virgins.” When? He had just closed a description of two kinds of
servants in chapter xxiv, one servant giving meat to his master’s
household in due season, the other smiting this good and faithful
servant, and in his heart saying, “My Lord delayeth his coming.” Just
then may the events connected with Advent history be compared
with the specifications of the parable. These two servants had been
engaged in the same work. But by some means one begins to say in
his heart, My Lord delayeth his coming, and smites his fellow. No
one who wished to see, could fail to see a clear fulfillment of this
illustration in the labors and general course of Advent ministers soon
after the passing of the time. All came up to that time apparently a
band of brothers. The time passed. Some became impatient and cast
away their confidence in the work, confessed to a scoffing church
and world, and because others would not confess as they had done,
that a human or satanic influence had controlled them, they were
ready to smite those who were strengthening the Master’s
household with the bread of Heaven.
The spiritual food for that time was by no means that teaching which
would let them down from the position they had taken, and send
them weeping and mourning back to Egypt. But meat in due season
was those expositions of God’s word which showed his hand in the
movement, and such cheering testimonies as are quoted in the
foregoing pages in vindication of the Advent movement. How
humiliating and painful the fact that Satan is permitted to bring the
spiritual warfare within the Second-Advent ranks.
5. That in the sense of the parable the Bridegroom had come. Come
where? Answer, To the marriage. Was the marriage of the Lamb to
take place in this world at the second appearing of Christ? The
Bridegroom had not come. But if the marriage of the Lamb was to
take place in Heaven, the position might be correct. And right here
the charge of our Lord to the waiting ones comes in with peculiar
force: “Let your loins be girded about, and your lights burning, and
ye yourselves like unto men that wait for their Lord when he will
return from the wedding.” Luke xii, 35, 36. If our Lord at his second
appearing returns from the wedding, then the marriage of the Lamb
must take place in Heaven prior to his return. Therefore, the coming
of the bridegroom in the parable illustrated some change in the
position and work of our great High Priest in Heaven in reference to
the marriage of the Lamb.
In a letter to the Voice of Truth for Feb. 19, 1845, William Miller
says:
“I presume, Bro. Marsh, you have seen Brn. Hale and Turner’s
Advent Mirror, printed in Boston, Jan., 1845, concerning the
marriage, in the parable of the virgins. I do believe in the main they
are right—that cannot be the personal coming of Christ. Why, say
you? Read Luke xii, 36: ‘And ye yourselves like unto men that wait
for their Lord, when he shall return from the wedding, that when he
cometh and knocketh, they may open to him immediately.’ You see
his coming, for which we look, is after the wedding.
“Has Christ come in the sense spoken of, Matt. xxv, 10? I think he
has.
“I know many of my brethren whom I highly esteem, will, and do,
disagree with me on this matter. I would advise them not to have
any hardness. Remember what James says, v, 9: ‘Grudge not one
against another, brethren, lest ye be condemned: behold the Judge
standeth before the door.’ It would seem that in this very time when
we have need of patience, the apostle, by the inspiration of the
divine Spirit, foresaw that there would be danger of grudging, or
grieving one another, and warns us not to do it, lest ye be
condemned: for ‘the Judge standeth before the door!’
“Let the dear brethren see to it, that we give meat in due season.
Let no one say in his heart, My Lord delayeth his coming, and begin
to beat and bruise, and grudge against his fellow-servant. He that
seeks to save his life now by conformity to the world, or worldly
men, will lose it; and he that loses his life now for the truth’s sake,
will find eternal life.”
6. That the established view, that in the marriage of the Lamb the
church is the bride of Christ, was among the errors of past times. By
investigation it was clearly seen that there were two things which
the Scriptures of the Old and New Testaments illustrate by marriage.
First, the union of God’s people in all past ages, as well as at the
present time, with their Lord. Second, Christ’s reception of the
throne of David, which is in the New Jerusalem. But union of
believers with their Lord has existed since the days of Adam, and
cannot be regarded as the marriage of the Lamb. It is supposed that
Isaiah [liv, 5,] speaks of the church when he says, “Thy Maker is
thine husband;” but Paul, in Gal. iv, applies this prophecy to the New
Jerusalem.
Says John, speaking of Christ, “He that hath the bride is the
bridegroom.” John iii, 29. That Christ is here represented in his
relation to his followers by a bridegroom, and his followers by a
bride, is true; but that he and they are here called the bridegroom
and bride, is not true. No one believes that the event called the
marriage of the Lamb took place eighteen hundred years since.
Paul, in writing to the church, 2 Cor. xi, 2, says, “I have espoused
you to one husband, that I may present you a chaste virgin to
Christ.” But does this prove that the marriage of the Lamb took place
in Corinth? Or, did Paul only wish to represent by marriage, the
union which he had effected, through the gospel, between Christ
and the church at Corinth?
He also says, Eph. v, 23, “For the husband is the head of the wife,
even as Christ is the head of the church.” But please turn and read
from verse 22, and it will be seen that Paul’s subject is the relation
and duty of man and wife to each other. This is illustrated and
enforced by the relation of Christ and the church. Those who
suppose that Paul is here defining who the Lamb’s wife is, are
greatly mistaken. That is not his subject. He commences, “Wives,
submit yourselves unto your own husbands.” Verse 22. “Husbands,
love your wives.” Verse 25. It is, indeed, an excellent subject, but
has nothing to do in determining what the bride is.
The marriage of the Lamb does not cover the entire period of
probation, in which believers are united to their Lord, from Adam to
the close of probation. It is one event, to take place at one point of
time, and that is just prior to the resurrection of the just.
Then what is the bride in the marriage of the Lamb? Said the angel
to John, “Come hither, I will show thee the bride, the Lamb’s wife.”
Rev. xxi, 9. Did the angel show John the church? Let John testify.
“And he carried me away in the Spirit to a great and high mountain,
and showed me that great city, the holy Jerusalem, descending out
of Heaven from God.” Verse 10.
The New Jerusalem is also represented as the mother. “But
Jerusalem which is above is free, which is the mother of us all.” Gal.
iv, 26. Christ is represented (Isa. ix, 6,) as the “everlasting Father” of
his people; the New Jerusalem, the mother, and the subjects of the
first resurrection, the children. And, beyond all doubt, the
resurrection of the just is represented by birth. How appropriate,
then, is the view that the marriage of the Lamb takes place in
Heaven before the Lord comes, and before the children of the great
family of Heaven are brought forth at the resurrection of the just.
Let those who are disposed to cling to the old view that the church
is the bride, and that the marriage is after Christ comes, and the
saints are caught up to Heaven, answer the following questions:
1. Who are illustrated by the man found at the marriage, Matt. xxii,
not having on the wedding garment?
2. Will any be caught up by mistake, to be bound hand and foot, and
be cast down to the earth again?
3. If the church is the wife, who are they that are called to the
marriage as guests?
4. Jerusalem above is the mother of the children of promise; but if
the church is the Lamb’s wife, who are the children?
5. That the door was shut. The clear light from the heavenly
sanctuary that a door, or ministration, was opened at the close of
the 2300 days, while another was closed at that time, had not yet
been seen. And in the absence of light in reference to the shut and
open door of the heavenly sanctuary, the reader can hardly see how
those who held fast their Advent experience, as illustrated by the
parable of the ten virgins, could fail to come to the conclusion that
probation for sinners had closed.
But light on the subject soon came, and then it was seen that
although Christ closed one ministration at the termination of the
2300 days, he had opened another in the most holy place, and still
presented his blood before the Father for sinners. As the high priest,
in the type, on the tenth day of the seventh month, entered the
most holy place, and offered blood for the sins of the people, before
the ark of the testament and the mercy-seat, so Christ, at the close
of the 2300 days, came before the ark of God and the mercy-seat to
plead his blood in behalf of sinners. Mark this: The great Redeemer
then approached the mercy-seat in behalf of sinners. Was the door
of mercy closed? This is an unscriptural expression, but, if I may be
allowed to use it, may I not say that in the fullest sense of the
expression the door of mercy was opened on the tenth day of the
seventh month, 1844?
Beside the ark of God containing the ten precepts of his holy law,
over which was the mercy-seat, did the trusting ones now behold
their merciful High Priest. They had stood in harmony with the whole
Advent host at the passing of the time, then represented as “the
church in Philadelphia;” meaning brotherly love. And with what
inexpressible sweetness did the following words addressed to that
church come home to their stricken hearts: “These things saith he
that is holy, he that is true, he that hath the key of David, he that
openeth, and no man shutteth; and shutteth, and no man openeth. I
know thy works. Behold, I have set before thee an open door, and
no man can shut it.” Rev. iii, 7, 8.
Adventists were agreed that the seven churches of Rev. ii and iii,
symbolized seven states of the Christian church, covering the entire
period from the first advent of Christ to his second appearing, and
that the sixth state addressed represented those who with one
united voice proclaimed the coming of Jesus, in the autumn of 1844.
This church was about to enter upon a period of great trial. And they
were to find relief from it, so far as ascertaining their true position is
concerned, by light from the heavenly sanctuary. After the light
should come, then would also come the battle upon the shut and
open door. Here was seen the connecting link between the work of
God in the past Advent movement, present duty to keep the
commandments of God, and the future glory and reward. And as
these views were taught in vindication of the Advent movement, in
connection with the claims of the Sabbath of the fourth
commandment, these men, especially those who had given up their
Advent experience, felt called upon to oppose. And their opposition,
as a general thing, was most violent, bitter, and wicked.
The shut and open door of the heavenly sanctuary constituted the
strong point upon which the matter turned. If we were right on the
subject of the cleansing of the sanctuary, then the door or
ministration of the holy place was shut, and the door or ministration
of the most holy place was opened, the 2300 days had ended, the
preaching of time was correct, and the entire movement was right.
But let our opponents show that we were in error upon the
sanctuary question, that Christ had not entered the most holy place
to cleanse the sanctuary, then the 2300 days had not ended, the
preaching of the time was an error, and the entire movement was
wrong. And, again, if the door or ministration of the most holy place
was opened, and the faith of the waiting ones was to view Jesus
standing before the mercy-seat and the ark of the ten
commandments in Heaven, how forcible the arguments for the
perpetuity and claims of the entire law of God, the fourth precept
not excepted. The hand of the Lord was with those who took a firm
position that the great Advent movement had been in his direct
providence, and that the time had come for the Sabbath reform, and
many embraced these views. Then it was that our opponents arose
in the spirit of persecution, manifesting the wrath of the dragon
against those who kept the commandments of God, and labored to
open the door that had been shut, and to shut that door which had
been opened, and thus put an end to the matter. Hence the strong
expressions quoted above—“He that openeth and no man shutteth,
and shutteth and no man openeth.” “Behold I have set before thee
an open door, and no man can shut it.” Nothing can be plainer than
that man, or a set of men, near the close of the history of the
church, would war against the truth of God in reference to the shut
and open door.
And to this day those who retain the spirit of war upon those who
keep the commandments of God, make the belief in the shut and
open door odious, and charge it all upon Seventh-day Adventists.
Many of them, however, are not unaware of the injustice of this.
Some of this people did believe in the shut door, in common with the
Adventists generally, soon after the passing of the time. Some of us
held fast this position longer than those did who gave up their
Advent experience, and drew back in the direction of perdition. And
God be thanked that we did hold fast to that position till the matter
was explained by light from the heavenly sanctuary.
And it may be worthy of notice that although the belief in, and
abandonment of, the shut-door position has been general, there
have been two distinct and opposite ways of getting out of it. One
class did this by casting away their confidence in the Advent
movement, by confessions to those who had opposed and had
scoffed at them, and by ascribing the powerful work of the Holy
Spirit to human or satanic influences. These got out of the position
on the side of perdition.
Another class heeded the many exhortations of Christ and his
apostles, applicable to their position, with its trials, dangers, and
duties—Watch—Be ye therefore patient—Cast not away therefore
your confidence—For ye have need of patience—Hold fast. They
waited, watched, and prayed, till light came, and they by faith in the
word saw the open door of the heavenly sanctuary, and Jesus there
pleading his precious blood before the ark of the most holy place.
But what was that ark? It was the ark of God’s testimony, the ten
commandments. Reader, please follow these trusting, waiting ones,
as they by faith enter the heavenly sanctuary. They take you into the
holy place and show you “the candlestick, and the table, and the
shewbread,” and other articles of furniture. Then they lead you into
the most holy where stands Jesus, clad in priestly garments, before
the mercy-seat which is upon, and but the cover of, the ark
containing the law of God. They lift the cover and bid you look into
the sacred ark, and there you behold the ten commandments, a
copy of which God gave to Moses. Yes, dear reader, there, safe from
the wrath of man and the rage of demons, beside his own holiness,
are the ten precepts of God’s holy law.
The waiting, watching, praying ones, embraced the fourth precept of
that law, and with fresh courage took their onward course to the
golden gates of the city of God, cheered by the closing benediction
of the Son of God: “Blessed are they that do his commandments,
that they may have right to the tree of life, and may enter in
through the gates into the city.” Thus they came out of the position
of the shut door on the side of loyalty to the God of high Heaven,
the tree of life, and the eternal city of the redeemed. The reader will
not fail to see the difference between their course and getting out of
the shut door on the side of perdition. God pity the apostate.
THE SEVENTH ANGEL.
The seventh angel, the last of the seven trumpet angels, had been
supposed to be the same as the “last trump,” which will awake the
righteous dead. But many among the Adventists were about this
time taking a different view of the subject. The six former trumpet
angels were symbols, and each had occupied a period of time,
during which a series of events took place. Why not the seventh be
a symbol covering a period of time, during which a series of events
might also transpire?
But the scenes connected with the last trump mentioned by the
apostle, are represented as transpiring “in a moment, in the
twinkling of an eye.” Not so with the events under the sounding of
the seventh angel. “But in the days of the voice of the seventh
angel,” is the testimony of Rev. x, 7. As this entire chapter has a
direct bearing upon the subject of the great Advent movement as
symbolized by the three messages of Rev. xiv, I will here give it with
a few brief remarks of application.
“And I saw another mighty angel come down from Heaven, clothed
with a cloud; and a rainbow was upon his head, and his face was as
it were the sun, and his feet as pillars of fire. And he had in his hand
a little book open: and he set his right foot upon the sea, and his left
foot on the earth, and cried with a loud voice, as when a lion
roareth: and when he had cried, seven thunders uttered their voices.
And the angel which I saw stand upon the sea and upon the earth,
lifted up his hand to Heaven, and sware by him that liveth forever
and ever, who created Heaven, and the things that therein are, and
the earth, and the things that therein are, and the sea, and the
things which are therein, that there should be time no longer.”
Verses 1-6.
I will briefly call attention to the following points in the above
quotation:
1. The angel, in a most solemn manner, swore that there should be
time no longer. This does not mean that with the oath of the angel,
time, as measured by days, months and years, would cease; for the
next verse speaks of the “days” of the voice of the seventh angel.
And even from the second advent of Christ and the resurrection of
the just, a thousand years are marked as reaching to the
resurrection of the unjust. In fact, while the earth and the sun and
moon shall endure and continue their revolutions, so long will there
be days, months and years. And there is no scripture evidence that
these bodies will ever cease to exist. The oath of the angel,
therefore, must refer to prophetic time.
2. The angel holds in his hand, as he swears upon the subject of
time, a little book open. It may be inferred from this language, that
this book was at some time closed up. This was true of the book of
Daniel. “But thou, O Daniel, shut up the words and seal the book,
even to the time of the end; many shall run to and fro, and
knowledge shall be increased.” Dan. xii, 4. It was to be sealed only
to the time of the end, when it was to be opened, knowledge of the
subject of which it treats should be increased, and many run to and
fro in the Scriptures and obtain knowledge upon the subject. If this
open book in the hand of the angel represents the unsealed book of
Daniel, how forcible the application of his solemn oath to the
manner in which the close of prophetic time was proclaimed in 1844.
The oath of this angel must be regarded as a symbol of a most
solemn and positive message proclaimed by the servants of God. His
right foot upon the earth, and his left upon the sea, represent its
extent, and shows that it was to be borne to the people by sea and
by land. The prophet continues:
“But in the days of the voice of the seventh angel, when he shall
begin to sound, the mystery of God shall be finished, as he hath
declared to his servants, the prophets.” Verse 7.
Why introduce the sounding of the seventh angel thus, unless his
sounding commenced with the termination of the prophetic time? He
is to continue his sounding a period of days, probably prophetic,
meaning years, and in the beginning of his sounding, or during the
first portion of the period of his sounding, the mystery of God is to
be finished. This mystery is the gospel considered with especial
reference to the means by which its blessings are secured to the
nations of the earth. It is something which, before the apostles’
days, even from the foundation of the world, was not made known
as it was then revealed. Rom. xvi, 25, 26; Eph. iii, 3-5. It was known
that the woman’s seed should bruise the serpent’s head, and that in
Abraham and his seed should all the nations of the earth be blessed;
but how this was to be accomplished was not understood till more
fully revealed at the first advent of the Saviour, and set forth by the
preaching of his apostles. Before this it was not seen that when the
Redeemer should be manifested to the world, all walls of partition
shall be broken down, all distinctions be obliterated, and Jew and
Gentile, male and female, bond and free, be on equal terms and in
equal measure blessed in him. Hence Paul presents as the
distinguishing feature of the mystery of God, the fact “that the
Gentiles should be fellow-heirs, and of the same body, and partakers
of the promise in Christ by the gospel,” and that in Christ all might
be gathered together in one. Eph. iii, 6; i, 9, 10. Hence we more
fully define the mystery of God to mean the great plan of salvation,
as it centers in the work of Christ, and is revealed in the New
Testament. See also Eph. vi, 19; Col. iv, 3; and Gal. i, 11, 12,
compared with Eph. iii, 3.
The finishing of the mystery of God is the completion of the great
plan of salvation in connection with Christ’s ministry in the heavenly
sanctuary. In the type the yearly round of service was finished on
the tenth day of the seventh month. In the antitype Christ entered
the most holy place of the heavenly sanctuary at the end of the
2300 days, to finish the great plan of salvation. The mystery of God
was to be finished, as he had declared by his servants, the prophets;
and the cleansing of the sanctuary spoken of by the prophet Daniel,
is only another expression signifying the same thing as the finishing
of the mystery of God. Hence the seventh angel began to sound at
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about books and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!

ebookgate.com

You might also like