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

Programming With C 3rd Edition Ravichandran pdf download

Ebook download

Uploaded by

daguebozi
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)
22 views

Programming With C 3rd Edition Ravichandran pdf download

Ebook download

Uploaded by

daguebozi
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/ 63

Programming With C 3rd Edition Ravichandran

download

https://ebookname.com/product/programming-with-c-3rd-edition-
ravichandran/

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


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

Programming problem solving abstraction with C Moffat

https://ebookname.com/product/programming-problem-solving-
abstraction-with-c-moffat/

Windows Forms Programming with C 1st Edition Erik Brown

https://ebookname.com/product/windows-forms-programming-
with-c-1st-edition-erik-brown/

Object Oriented Programming With C 4th Edition E.


Balagurusamy

https://ebookname.com/product/object-oriented-programming-
with-c-4th-edition-e-balagurusamy/

Storytown Winning Catch Grade 4 Reader 1st Edition


Harcourt School Publishers

https://ebookname.com/product/storytown-winning-catch-
grade-4-reader-1st-edition-harcourt-school-publishers/
The State of Southern Illinois An Illustrated History
1st Edition Herbert K. Russell

https://ebookname.com/product/the-state-of-southern-illinois-an-
illustrated-history-1st-edition-herbert-k-russell/

Latin American Novels of the Conquest Reinventing the


New World 1st Edition Kimberle S. Lopez

https://ebookname.com/product/latin-american-novels-of-the-
conquest-reinventing-the-new-world-1st-edition-kimberle-s-lopez/

Surface and Interface Science Volume 3 and 4 Volume 3


Properties of Composite Surfaces Volume 4 Solid Solid
Interfaces and Thin Films 1st Edition Klaus Wandelt

https://ebookname.com/product/surface-and-interface-science-
volume-3-and-4-volume-3-properties-of-composite-surfaces-
volume-4-solid-solid-interfaces-and-thin-films-1st-edition-klaus-
wandelt/

Pro HTML5 and CSS3 Design Patterns 1st Edition Michael


Bowers

https://ebookname.com/product/pro-html5-and-css3-design-
patterns-1st-edition-michael-bowers/

Scanner Data and Price Indexes Robert C. Feenstra

https://ebookname.com/product/scanner-data-and-price-indexes-
robert-c-feenstra/
Introduction to 3G Mobile Communications 2nd ed Edition
Juha Korhonen

https://ebookname.com/product/introduction-to-3g-mobile-
communications-2nd-ed-edition-juha-korhonen/
Programming with

C++
Third Edition
About the Author

D Ravichandran is currently based in Hyderabad and is a corporate trainer in software engineering, data
structures and algorithms, and programming languages. He was earlier a senior faculty in the Department
of Computing, Middle East College of Information Technology, Muscat, Sultanate of Oman. He was also
a faculty member of Department of Computer Science and Engineering, Pondicherry Engineering College,
Pondicherry, for more than 15 years. He is an expert in several computer programming languages and has
more than two decades of professional programming experience. A prolific writer, he has already published
many books in the field of computer science and information technology. His affiliations include a life
membership of the Indian Society for Technical Education and a membership of the Computer Society of
India.
Programming with

C++
Third Edition

D Ravichandran
Corporate Trainer in Software Engineering
Data Structures and Algorithms and Programming Languages
Hyderabad

Tata McGraw Hill Education Private Limited


NEW DELHI
McGraw-Hill Offices
New Delhi New York St Louis San Francisco Auckland Bogotá Caracas
Kuala Lumpur Lisbon London Madrid Mexico City Milan Montreal
San Juan Santiago Singapore Sydney Tokyo Toronto
Published by the Tata McGraw Hill Education Private Limited,
7 West Patel Nagar, New Delhi 110 008.

Programming with C++, 3/e

Copyright © 2011, 2003, 1996, by Tata McGraw Hill Education Private Limited.
No part of this publication may be reproduced or distributed in any form or by any means,
electronic, mechanical, photocopying, recording, or otherwise or stored in a database or
retrieval system without the prior written permission of the publishers. The program listing
(if any) may be entered, stored and executed in a computer system, but they may not be
reproduced for publication.

This edition can be exported from India only by the publishers,


Tata McGraw Hill Education Private Limited.

ISBN-13 digits: 978-0-07-068189-7


ISBN-10 digits: 0-07-068189-9

Vice President and Managing Director—McGraw-Hill Education: Asia Pacific Region: Ajay Shukla

Head—Higher Education Publishing and Marketing: Vibha Mahajan


Manager: Sponsoring—SEM & Tech Ed: Shalini Jha
Asst Sponsoring Editor: Surabhi Shukla
Development Editor: Surbhi Suman
Executive—Editorial Services: Sohini Mukherjee
Jr Production Manager: Anjali Razdan
Dy Marketing Manager—SEM & Tech Ed: Biju Ganesan
General Manager—Production: Rajender P Ghansela
Asst General Manager—Production: B L Dogra

Information contained in this work has been obtained by Tata McGraw-Hill, from sources believed to be reliable.
However, neither Tata McGraw-Hill nor its authors guarantee the accuracy or completeness of any information
published herein, and neither Tata McGraw-Hill nor its authors shall be responsible for any errors, omissions,
or damages arising out of use of this information. This work is published with the understanding that Tata
McGraw-Hill and its authors are supplying information but are not attempting to render engineering or other
professional services. If such services are required, the assistance of an appropriate professional should be sought.

Typeset at Bukprint India, B-180A, Guru Nanak Pura, Laxmi Nagar-110 092 and printed at
Avon Printers, Plot No. 16, Main Loni Road, Jawahar Nagar, Industrial Area, Shahdara, Delhi 110 094

Cover Printer: SDR Printers

RQXCRRQZDLCZL
Dedicated to my son

Suseekaran
for his love and support
Contents

Preface to the Third Edition xv


Acknowledgements ix

1. Introduction to Object Oriented Programming 1


1.1 Introduction 1
1.2 What is Object Oriented Programming (OOP)? 2
1.3 Structured Procedural Programming (SPP) 2
1.4 Object Oriented Programming OPP 3
1.5 Characteristics of OOPs 3
1.6 Advantages of OOPs 6
1.7 Disadvantages of OOPs 7
1.8 Comparison of Structured Procedural Programming (SPP) and Object Oriented Programming
(OOP) 7
1.9 Steps in Developing OOP Programs 8
1.10 Structure of Object Oriented Programs 9
1.11 Object Oriented Languages 11
1.12 Importance of C++ 11
Review Questions 12

2. Building ANSI C++ Program 13


2.1 Introduction 13
2.2 History of C++ 13
2.3 The Latest Addenda to ANSI/ISO C++ 15
2.4 Possible Future Additions to C++ 16
2.5 C++ versus C 16
2.6 Versions of C++ 17
2.7 Source Program Names 17
2.8 Compiling and Debugging C++ Programs 17
2.9 Stages of Program Development 18
2.10 Compiling GNU GCC/G++ in Linux 20
2.11 Compiling C/C++ Program in UNIX 21
2.12 Building C++ Under Microsoft .NET Platform 22
Review Questions 31
viii Contents

3. Data Types, Operators and Expressions 32


3.1 Identifiers and Keywords 32
3.2 Data Types 34
3.3 C++ Simple Data Types 35
3.4 Literals 38
3.5 Variables 43
3.6 The Const Datatype 45
3.7 C++ Operators 46
3.8 Arithmetic Operators 46
3.9 Assignment Operators 50
3.10 Arithmetic Assignment Operators 51
3.11 Comparison and Logical Operators 52
3.12 Bitwise Operators 58
3.13 Bitwise Assignment Operators 62
3.14 Special Operators 63
3.15 Type Conversion 66
3.16 ANSI C++ Type Casting 68
3.17 Summary of ANSI C++ Operators 69
3.18 ANSI C++ Alternate Punctuation Tokens 71
Review Questions 71
Concept Review Questions 72
4. Input and Output Streams 75
4.1 Comments 75
4.2 Declaration of Variables 76
4.3 The Main () Function 77
4.4 Simple C++ Programs 77
4.5 Program Termination 79
4.6 Features of Iostream 80
4.7 Keyboard and Screen I/O 83
4.8 Manipulator Functions 86
4.9 Input and Output (I/O) Stream Flags 93
Review Questions 105
Concept Review Problems 106
Programming Exercises 111
5. Control Statements 112
5.1 Conditional Expressions 112
5.2 Loop Statements 132
5.3 Nested Control Structures 151
5.4 Breaking Control Statements 153
Review Questions 159
Concept Review Problems 160
Programming Exercises 176
Contents ix

6. Functions and Program Structures 179


6.1 Introduction 179
6.2 Defining a Function 180
6.3 The Return Statement 182
6.4 Function Prototypes 183
6.5 Types of User Defined Functions 185
6.6 Actual and Formal Arguments 198
6.7 Local VS Global Variables 200
6.8 Default Arguments 202
6.9 Structure of the C++ Program 205
6.10 Order of the Function Declaration 208
6.11 Mutually Invocated Functions 211
6.12 Nested Functions 212
6.13 Scope Rules 214
6.14 Side Effects 216
6.15 Storage Class Specifiers 217
6.16 Recursive Functions 226
6.17 Preprocessors 229
6.18 Header Files 235
6.19 Standard Functions 235
Review Questions 235
Concept Review Problems 236
Programming Exercises 247

7. Arrays 248
7.1 Introduction 248
7.2 Array Notation 249
7.3 Array Declaration 249
7.4 Array Initialisation 250
7.5 Processing with Arrays 252
7.6 Arrays and Functions 259
7.7 Multidimensional Arrays 266
7.8 Character Array 276
Review Questions 285
Concept Review Problems 286
Programming Exercises 291

8. Pointers and Strings 293


8.1 Introduction 293
8.2 Pointer Arithmetic 299
8.3 Pointers and Functions 305
8.4 Pointers to Functions 311
8.5 Passing a Function to Another Function 314
8.6 Pointers and Arrays 316
8.7 Arrays of Pointers 319
x Contents

8.8 Pointers and Strings 320


8.9 Pointers to Pointers 327
8.10 Deciphering Complex Declarations 329
Review Questions 331
Concept Review Problems 332
Programming Exercises 339

9. Structures, Unions and Bit Fields 340


9.1 Introduction 340
9.2 Declaration of a Structure 341
9.3 Processing with Structures 343
9.4 Initialisation of Structure 350
9.5 Functions and Structures 352
9.6 Arrays of Structures 357
9.7 Arrays within a Structure 361
9.8 Structures within a Structure (Nested Structure) 368
9.9 Pointers and Structures 375
9.10 Unions 379
9.11 Bit Fields 383
9.12 Typedef 386
9.13 Enumerations 389
Review Questions 391
Concept Review Problems 392
Programming Exercises 396

10. Classes and Objects 398


10.1 Introduction 398
10.2 Structures and Classes 399
10.3 Declaration of a Class 401
10.4 Member Functions 405
10.5 Defining the Object of a Class 407
10.6 Accessing a Member of Class 409
10.7 Array of Class Objects 423
10.8 Pointers and Classes 426
10.9 Unions and Classes 430
10.10 Classes within Classes (Nested Class) 432
10.11 Summary of Structures, Classes and Unions 439
Review Questions 440
Concept Review Problems 440
Programming Exercises 449

11. Special Member Functions 454


11.1 Introduction 454
11.2 Constructors 455
11.3 Destructors 470
Contents xi

11.4 Inline Member Functions 476


11.5 Static Class Members 481
11.6 Friend Functions 487
11.7 Dynamic Memory Allocations 496
11.8 This Pointer 502
11.9 Mutable 505
Review Questions 506
Concept Review Problems 506
Programming Exercises 513

12. Single and Multiple Inheritance 518


12.1 Introduction 518
12.2 Single Inheritance 520
12.3 Types of Base Classes 524
12.4 Types of Derivation 531
12.5 Ambiguity in Single Inheritance 534
12.6 Array of Class Objects and Single Inheritance 536
12.7 Multiple Inheritance 538
12.8 Container Classes 549
12.9 Member Access Control 552
12.10 Summary of the Inheritance Access Specifier 568
Review Questions 568
Concept Review Problems 569
Programming Exercises 581

13. Overloading Functions and Operators 584


13.1 Function Overloading 584
13.2 Operator Overloading 607
13.3 Overloading of Binary Operators 612
13.4 Overloading of Unary Operators 617
Review Questions 621
Concept Review Problems 622
Programming Exercises 632

14. Polymorphism and Virtual Functions 633


14.1 Polymorphism 633
14.2 Early Binding 634
14.3 Polymorphism with Pointers 638
14.4 Virtual Functions 641
14.5 Late Binding 644
14.6 Pure Virtual Functions 653
14.7 Abstract Base Classes 656
14.8 Constructors Under Inheritance 659
14.9 Destructors Under Inheritance 661
14.10 Virtual Destructors 664
xii Contents

14.11 Virtual Base Classes 668


Review Questions 673
Concept Review Problems 674
Programming Exercises 685

15. Templates, Namespace and Exception Handling 689


15.1 Function Template 689
15.2 Class Template 694
15.3 Overloading of Function Template 698
15.4 Exception Handling 703
15.5 Namespace 710
Review Questions 724
Concept Review Problems 725
Programming Exercises 735

16. Data File Operations 736


16.1 Opening and Closing of Files 736
16.2 Stream State Member Functions 738
16.3 Reading/Writing a Character from a File 740
16.4 Binary File Operations 745
16.5 Classes and File Operations 747
16.6 Structures and File Operations 753
16.7 Array of Class Objects and File Operations 754
16.8 Nested Classes and File Operations 757
16.9 Random Access File Processing 761
Review Questions 766
Programming Exercises 767

17. STL–Containers Library 768


17.1 Introduction 768
17.2 Vector Class 769
17.3 Double Ended Queue (Deque) Class 772
17.4 List Class 775
17.5 Stack Class 777
17.6 Queue Class 781
17.7 Priority_queue Class 786
17.8 Set 788
17.9 Multiset 789
17.10 Map 790
17.11 Multimap 792
17.12 Bitset 793
Review Questions 793

18. STL–Iterators and Allocators 795


18.1 Introduction 795
Contents xiii

18.2 Types of Iterators 796


18.3 <Iterator> Member Functions 796
18.4 Operators 800
18.5 Types of Iterator Classes 801
18.6 Summary of Iterator Classes 802
Review Questions 803

19. STL–Algorithms and Function Objects 804


19.1 Introduction 804
19.2 Non-modifying Sequence Algorithms 805
19.3 Modifying Sequence Algorithms 806
19.4 Sorted Sequence Algorithms 810
19.5 Heap Operation Algorithms 812
19.6 Comparison Algorithms 812
19.7 Permutation Algorithm 813
19.8 Numeric Algorithms 813
19.9 Function Objects 814
19.10 The Functional Members 814
Review Questions 818

Appendix 820
Bibliography 836
Index 838
Preface to the Third Edition

The book not only discusses the issues concerning the mystery of ANSI C++ but also makes a conscious
effort to relate those insights to contemporary programming. This timeless and enlightening information
is presented in a clear and concise manner. The new edition offers a fresh perspective of what ANSI C++
means and where ANSI C++ fits into the scheme of software life cycles. Thus, readers can gain requisite
expertise by acquiring ANSI C++ programming skills and design ideas.

Aim of the Book


A welcome introduction to the world of programming, this book discloses facts and techniques on ANSI/
ISO C++ and provides a knowledge base for advanced, standard-compliant, and efficient use of C++.
It not only covers the syntax and semantics of ANSI C++ but also reveals the secrets of object-oriented
programming through various topics, namely, classes, objects, inheritance, polymorphism and dynamic
binding, and generic programming through STL. It offers stimulating insights into the loftiest thoughts and
realisations of what ANSI C++ is and its relationship to modern software life cycles. A must read for all
those who want to increase their understanding and awareness of object-oriented programming concepts,
the book also serves the purpose of a handy reference for C++ programming professionals.

Users
The target audience for this book is two-fold—(i) computer novices who do not have any prior programming
knowledge, and (ii) experienced C++ developers who seek a guide for enhancing their design and
programming proficiency. Specifically, it can be used by undergraduate students of CSE, IT, ECE, EEE,
Electronics and Instrumentation Engineering, BCA/MCA, and BSc/MSc (Computer Science/IT). Moreover, it
would be an ideal reference for students of diploma and DOEACC courses in computer science and computer
training institutes.

New to the Edition


∑ Broader and in-depth coverage of Object Oriented Programming concepts in 2 new chapters—
Chapter 1: Introduction to Object Oriented Programming and Chapter 2: Building ANSI C++ Programs
∑ Detailed coverage of Standard Template Libraries (STL) in three new chapters—Chapters 17:
STL - Containers, Chapter 18: STL - Iterators and Chapter 19: STL - Algorithms and Function Objects
∑ Enhanced coverage for topics such as data types, arithmetic operators, IOStreams, functions and
program structures, special member functions, and exception handling
∑ Inclusion of new section on Namespaces in Chapter 15: Templates, Namespace and Exception Handling
xvi Preface to the Third Edition

Salient Features
The revised edition has been thoroughly updated with ANSI/ISO C++ syntax. This text offers one of
the best reviews of ANSI C++ since it gives access to the most important concepts in object-oriented
programming found anywhere. It introduces the syntax and features of C++ programming languages in
a simple manner. The concepts are very well exemplified with program codes containing the inputs and
outputs of the sample programs. It first explains the basic concepts (like functions, arrays, pointers and
structures) and then progresses with the discussion on OOP concepts (like classes, objects, inheritance,
polymorphism and templates) which will be helpful for the beginners in better understanding of the
implementation and applications of the C++ language.
The book is impregnated with the following salient features:
∑ Offers a concise introduction to C++ and Object-Oriented Programming (OOP).
∑ Emphasises the use of software tools and covers the software engineering topics in detail.
∑ Provides pictorial representation in the form of syntax diagrams, flowcharts and Object Modeling
Technique (OMT) class notation diagrams given.
∑ Elucidates the language features through executable codes which are tested on various compilers such
as Linux GNU C++ and .Net Microsoft Visual C++.
∑ Facilitates the readers with simple and easy-to-understand format of the program execution (i.e.,
sample input and output).
∑ Explains how to avoid and correct typical errors.
∑ Describes concept review problems to test programming proficiency of readers on various ANSI C++
topics in a special section. Interactive exercises using the computer make learning fun.
∑ Refreshed and enhanced pedagogy includes Programming Examples (359), Review Questions
(439), Concept Review Problems (380) and Programming Exercises (197). Answers to the
Concept Review Problems are included in the Appendix.
The pedagogical features and their benefits are explained below:

Highlights Description and Benefit Examples


Introduction Each chapter begins with an Introduction which helps the reader Refer pages
get a brief summary of the background and contents of the chapter. 1, 13, 32, etc.
Sections and Sub- Object-oriented programming using C++ is one of the most widely Refer pages
sections discussed, debated, and examined elements of modern software 35, 63, 79,
life cycles, and also one of the most mysterious and misunderstood etc.
subjects. Therefore, each chapter has been neatly divided into
sections and sub-sections so that the subject matter is studied in a
logical progression of ideas and concepts.
Programming code A set of programming codes, totaling to 314 problems is present in Refer pages
with sample input relevant chapters. All sample programs are well graded and tested 87, 130, 222,
and output using the different versions of the ANSI C++ compiler. etc.
These self-learning codes with sample inputs and outputs enable
students to strive towards better comprehension of the concepts and
also, master the programming skills.
Preface to the Third Edition xvii

Highlights Description and Benefit Examples


Flowcharts and Flowcharts and syntax diagrams presented at appropriate locations Refer pages
Diagrams demystify the complexity of the difficult topics like pointers, 114, 133, 141,
strings, streams, inheritance polymorphism, file handling, etc.
templates, etc. Object Modeling Technique (OMT) diagrams easily
illustrate the advance topics, functional relationships and definition
sketches for mathematical models.
Review Questions These are very useful for the faculty in setting class work, Refer pages
assignments, quizzes and examinations and help students in 13, 31, 71,
revising the learnt concepts. etc.
Programming This section takes an unbiased look at some of the more interesting Refer pages
Exercises and relevant ideas relating to programming. The practice questions 111, 176, 247,
help students get a clearer picture of the software design and etc.
coding.
Concept Review This section concentrates on a wide range of concepts such as Refer pages
Problems syntax and semantic analysis of the code, spotting and identifying 72, 105, 160,
the logical errors, technical and complexity analysis. This enhances etc.
your knowledge and understanding of software engineering and
also, improves your programming skills.
Answers to Concept Answers provided for all the Concept Review Problems at the end Refer pages
Review Problems of the book as Appendix A help check your understanding of the 820, etc.
learnt concepts.
References and A comprehensive list of references given at the end of the book Refer pages
Bibliography further enhances the subject knowledge. 836, etc.

Organisation
This book consists of nineteen chapters which are as follows:
Chapter 1 presents the concepts and features of Object-Oriented Programming (OOP) and highlights
some of the key terms of the OOP paradigm which are extensively used in this book.
Chapter 2 gives an overview of the latest addenda to ANSI/ISO C++ compiler and also suggests how
to build an ANSI C++ program under various platforms, namely, GNU C++ for Linux and .Net VC++ for
Windows.
Chapter 3 introduces the fundamentals of C++ programming language and summarises the most
significant data types, operators and expressions used in ANSI C++.
Chapter 4 focuses on developing simple C++ programs with emphasis on the Input and Output Streams
<iostream> and highlights the features of manipulator functions and Input and Output (I/O) stream flags.
Chapter 5 describes the principles and guidelines in the design and evolution of C++ through control
statements which has become the standard for any programming language.
Chapter 6 deals with user-defined functions and program structures and stresses on how to define
and use the different types of arguments (namely, actual, formal, local and global variables); how to use the
recursive functions, nested functions and preprocessors.
xviii Preface to the Third Edition

Chapter 7 explains the importance of array data types in C++. It describes how to define, declare and
use single dimensional, multidimensional and character arrays. Array notation, array initialisation and types
of data storage such as static, automatic, and free store are also dealt with numerous examples.
Chapter 8 delves on the syntax and semantics of pointer data type which is one of the strengths of the
C++ language. In addition, it demonstrates the use of strings and advanced memory management techniques
using complex pointer data types and also guides the user how to avoid common pointer related errors.
Chapter 9 deals with functional characteristics of structure and union data types. It also describes how
to declare, define and use the array of structure, structure within structure, pointer to structure, union tags
and bit fields.
Chapter 10 elucidates the salient features of object-oriented programming and explains how classes and
objects can be defined, declared and used in C++. Special attention is given for defining the various types
of class declarations.
Chapter 11 covers the syntax and semantics of the special member functions such as constructors,
destructors, inline member functions, static class members and friend functions as well as their role in
class design. It also demonstrates several techniques and guidelines for an effective usage of these special
member functions.
Chapter 12 discusses one of the most important features of the OOP, namely, inheritance. Single and
multiple inheritance, types of derivation, public inheritance, private inheritance, protected inheritance,
container classes and member access control are explained with suitable number of examples.
Chapter 13 exemplifies the concepts of function and operator overloading, and explores the benefits
as well as the potential problems of operator overloading. It discusses the restrictions that apply to operator
overloading and also explains how to avoid the common errors while using operator and function overloading.
Chapter 14 narrates the central attraction of the OOP—polymorphism with pointers and virtual
functions. Early binding, virtual functions, late binding, pure virtual functions, abstract base classes,
constructors under inheritance, destructors under inheritance, virtual destructors and virtual base classes are
presented, with well-graded examples.
Chapter 15 presents the various aspects of designing and implementing templates, including class
templates, function templates, and template issues that are of special concern. This chapter describes the
standard exception handling using the keywords—try, catch and throw. It also elucidates the rationale
behind the addition of namespaces to the language and the problems that namespaces solve. Furthermore,
how to declare, define and use the namespace alias, nested namespace, unnamed namespace and namespace
std, are covered in this chapter.
Chapter 16 gives the data file operations in C++ and focuses on how to read and write a class of
objects from the files of secondary storage devices. The ANSI-ISO C++ streams and file processing
commands are dealt with suitable illustrations.
Chapters 17–19 provide coverage on introduction to the Standard Template Library (STL) and
generic programming in general. It discusses the principles of generic programming, focusing on STL
as an exemplary framework of generic programming. These chapters also demonstrate the use of STL
components such as containers, algorithms, iterators, allocators, adapters, binders, and function objects.

Online Learning Center


The accompanying web supplement http://www.mhhe.com/ravichandran/cp3e provides an additional
resource for students and instructors.
Preface to the Third Edition xix

Acknowledgements
I am grateful to Dr T Sundararajan, Professor, Department of Civil Engineering, Pondicherry Engineering
College, for his timely support, encouragement, valuable comments, suggestions and many innovative ideas
in carrying out this project. I am indebted to my teachers, mentors and professors who taught me the art of
computer programming during my studentship at Indian Institute of Technology, Kharagpur, especially, to
Prof. Swapna Banerjee, Prof. N B Chakaraborthy and Prof. J C Biswas.
I extend my appreciation to Mr Christian Wolff, Heidelberg, Germany, for his continuous motivation, love
and advice in my life. I would like to express my gratitude towards Mr Arun, Mr Walid, Mr Shariq Ali and
Dr. Gulam Ahmed, Middle East College of Information Technology, Muscat, Sultanate of Oman, for their
technical comments and suggestions. I am thankful to my students [in India and abroad] who have helped
me a lot in bringing out this edition and would like to specially acknowledge the efforts of Mr Al Walid
Al Busaidi, Muscat; Mr Ashwin Kumar Chummun, UK; Mr Gowathaman, France; Mr Sampath Reddy,
US; Mr Sudheer Reddy, US; Mr Tushar Ranjan Sahoo and Dr Ram Niranjan Sahoo JIPMER, Pondicherry.
My earnest thanks are also due to the editorial and publishing professionals at Tata McGraw-Hill for
their keen interest and support in bringing out this book in record time. There have been several professors
who have participated in the review process of this book. I would like to sincerely acknowledge them for
their valuable suggestions and encouragement.

Akshay Girdhar
Guru Nanak Dev Engineering College, Ludhiana, Punjab
Amit Jain
Bharat Institute of Technology, Meerut, Uttar Pradesh
Harish Kumar
Panjab University, Chandigarh, Punjab
Prashant Sharma
Anand Engineering College, Agra, Uttar Pradesh
Dinesh Kumar Tyagi
Birla Institute of Technology and Science, Pilani, Rajasthan
Md Tanwiruddin Haider
National Institute of Technology, Patna, Bihar
Mahua Banerjee
Xavier Institute of Social Service, Ranchi, Jharkhand
xx Acknowledgements

N K Kamila
C V Raman College of Engineering, Bhubaneswar, Orissa
Pranam Paul
Dr B C Roy Engineering College, Kolkata, West Bengal
Sajal Mukhopadhya
National Institute of Technology, Durgapur, West Bengal
Kanhaiya Lal
Birla Institute of Technology, Patna, Bihar
Poornachandra Sarang
University of Mumbai, Mumbai, Maharashtra
Manisha J Somavanshi
Indira Institute of Management, Pune, Maharashtra
T V Gopal
Anna University, Chennai, Tamil Nadu
N Shanthi
K S Rangasamy college of Technology, Tiruchengode, Tamil Nadu
Annappa
National Institute of Technology, Surathkal, Karnataka
CH V K N S N Moorthy
R K Institute of Science and Technology, Hyderabad, Andhra Pradesh
M M Naidu
S V University College of Engineering, Tirupati, Andhra Pradesh
Finally, I thank my parents, son and wife for the love, encouragement and comfort they have
extended to me throughout my career.

D Ravichandran

Feedback
The readers of the book are encouraged to send their comments, queries and suggestions at
the following email id—tmh.csefeedback@gmail.com, mentioning the title and author name in the
subject line. Also, please report to us any piracy of the book spo ed by you.
Chapter
Introduction to Object
Oriented Programming 1
This chapter focuses on the definitions, basic concepts and salient features
of Object Oriented Programming (OOP). The pros and cons of Structured
Procedural Programming (SPP) with Object Oriented Programming (OOP) are
also summarised. Major applications of OOP are also highlighted in this chapter.
It also describes how C++ can be used to improve productivity and so ware
quality by offering features such as classes, objects, data hiding, encapsulation,
inheritance, polymorphism and templates.

1.1 INTRODUCTION

A major challenge for software engineering today is to improve the software programming process as
modern software life cycle has been changing very dramatically since the late nineties wherein the code
re-usability, reliability and maintainability are the key features. The very aim of using an object oriented
programming language is to handle a complex software design in a very easy, simple and efficient manner.
Redesigning and maintaining the source code costs much more than the reusability of the source code. The
turnover time and software cost are drastically brought down. The main aim of designing the C++ language
is to support both a procedure oriented style and an object oriented programming paradigm. In that sense,
C++ is a hybrid language which supporzts both the procedural as well as object oriented programming
styles.
Softwares designed using object oriented technology can meet up the challenges of large real world
systems by enhancing the ability to produce reliable and maintainable code. Through object oriented
programming and design, such software can naturally evolve to meet changing needs. To effectively
accomplish this, one must learn new ways of thinking about programming and problem solving.
Therefore, Object Technology (OT) is drawing attention and consideration in many areas of computing,
such as
∑ programming
∑ data bases
2 Programming with C++

∑ system analysis and design


∑ computer architecture
∑ operating systems
∑ expert systems, and
∑ internet client/server programming

1.2 WHAT IS OBJECT ORIENTED PROGRAMMING OOP ?

Object oriented programming, or OOP, is a software development philosophy based on the following
central ideas:
∑ encapsulation
∑ inheritance
∑ information hiding
∑ data abstraction and
∑ polymorphism
Object Oriented Programming has revolutionised the very art and practice of writing computer
applications. Object is the basic unit of object oriented programming. Designing an object-oriented model
involves defining a set of classes. A class is a template from which objects are created. The template, or
blueprint, provided by a class specifies a set of data and methods that all objects created according to its
specifications will contain.
Hence, the object oriented programming approach has the advantage of producing more reliable
softwares for complex and large-scale systems.

1.3 STRUCTURED PROCEDURAL PROGRAMMING SPP

In the late seventies, Structured Procedural Programming


(SPP) was widely used for designing and developing
softwares. Structured programming is a programming
paradigm that to a large extent relies on the idea of
dividing a program into functions and modules (Fig. 1.1).
As programs became larger for real life applications,
they were broken down into smaller units, such as functions,
procedures, and subroutines. Functions can be grouped
Fig. 1.1 Procedural Programming Approach
together into modules according to their functionality,
objectives and tasks. In other words, SPP emphasises mostly functional decomposition and procedural
abstraction for designing and developing software systems.
However, SPP was found to be unsuitable for handling complex software systems due to lack of code
reusability, extensibility and maintainability. One of the main drawbacks of SPP is that data and functions
have to be stored separately and the data has to be globally accessed, as the systems are modularised on the
basis of functions. Information hiding and data encapsulation are not supported in SPP and therefore, every
function can access every piece of data. Functions have unrestricted access to global data. Changing the
global data in a module causes program side effects and that code becomes unreliable and error prone in a
complex system.
Some of the examples for procedural languages are ‘C’, Pascal, and Fortran.
Introduction to Object Oriented Programming 3

It is well known that ‘C’ is widely accepted as a well structured programming language for a variety of
applications. It has many advantages over other high level programming languages. But it has flaws and
limitations that has made it unsuitable for complex programming projects.

1.4 OBJECT ORIENTED PROGRAMMING OOP


Object Oriented Programming (OOP) alleviates
some of the problems mentioned above. The
OOP approach has the advantage of producing
better structured and more reliable softwares
for complex systems, greater reusability, more
extensibility, and easy maintainability.
In object oriented programming, systems
are modularised on the basis of data structures
(objects). Object’s state (data types) and
behavior (operations) are encapsulated. Message
passing ensures that an object’s internal state can
be accessed only if permitted, as encapsulation
Fig. 1.2 Object Oriented Programming (OOP)
prevents unauthorised access (Fig. 1.2).
Approach
Real world is represented more closely by
objects mimicking external entities. Objects of the program interact by sending messages to each other.
Each object is responsible to initialise and destroy itself correctly. Consequently, there is no longer the
need to explicitly call a creation or termination procedure.

1.5 CHARACTERISTICS OF OOPs

Following are the major characteristics for considering any programming languages to be object oriented:
∑ objects
∑ classes
∑ data abstraction
∑ data encapsulation
∑ information hiding
∑ message passing
∑ inheritance
∑ dynamic binding
∑ polymorphism, and
∑ overloading

1.5.1 Objects
In Object Oriented Programming (OOP) paradigm, objects are the fundamental building blocks for
designing a software. In other words, an object is a collection of data members and the associated member
functions are known as methods. Objects are identified by its unique name (Fig. 1.3(b)). An object
represents a particular instance of a class. There can be more than one instance of an object. Each instance
of an object can hold its own relevant data.
Another Random Document on
Scribd Without Any Related Topics
relationship suggests the previous wings, the woman is able to escape the
fallen monster by the two wings given her.4 Wingless now, ‘the old serpent’
once more, the monster’s shape has no adaptation to the moral and religious
struggle which is to ensue. For his shape is a method, and it means the
perfection of brute force. That, indeed, also remains in the sequel of this
magnificent myth. As in the legend of the Hydra two heads spring up in
place of that which falls, so in this Christian legend out of the overthrown
monster, henceforth himself concealed, two arise from his inspiration,—the
seven-headed, ten-horned Beast who continues the work of wrath and pain;
but also a lamb-like Beast, with only two horns (far less terrible), and able
to deceive by his miracles, for he is even able to call down fire from
heaven. The ancient Serpent-dragon, the expression of natural pain, thus
goes to pieces. His older part remains to work mischief and hurt; and the
cry is uttered, ‘Be merry, ye heavens, and ye that tabernacle in them: woe to
the earth and the sea! for the devil is come down unto you, having great
wrath because he knows that he has a short time.’5 But there is a lamb-like
part of him too, and his relation to the Dragon is only known by his voice.

This subtle adaptation of the symbol of external pain to the representation


of the moral struggle, wherein the hostile power may assume deceptive
forms of beauty and pleasure, is only one impressive illustration of the
transfer of human conceptions of evil from outward to inward nature. The
transition is from a malevolent, fatal, principle of harmfulness to the body
to a malevolent, fatal, principle of evil to the conscience. The Demon was
natural; the Dragon was both physical and metaphysical; the Devil was and
is theological. In the primitive Zoroastrian theology, where the Devil first
appears in clear definition, he is the opponent of the Good Mind, and the
combat between the two, Ormuzd and Ahriman, is the spiritualisation of the
combat between Light and Darkness, Pain and Happiness, in the external
world. As these visible antagonists were supposed to be exactly balanced
against each other, so are their spiritual correlatives. The Two Minds are
described as Twins.

‘Those old Spirits, who are twins, made known what is good and what is
evil in thoughts, words, and deeds. Those who are good distinguished
between the two; not so those who are evil-doers.
‘When these two Spirits came together they made first life and death, so
that there should be at last the most wretched life for the bad, but for the
good blessedness.

‘Of these two Spirits the evil one chose the worst deeds; the kind Spirit, he
whose garment is the immovable sky, chose what is right.’6

This metaphysical theory follows closely the primitive scientific


observations on which it is based; it is the cold of the cold, the gloom of the
darkness, the sting of death, translated into some order for the intellect
which, having passed through the Dragon, we find appearing in this Persian
Devil; and against his blackness the glory of the personality from whom all
good things proceed shines out in a splendour no longer marred by
association with the evil side of nature. Ormuzd is celebrated as ‘father of
the pure world,’ who sustains ‘the earth and the clouds that they do not fall,’
and ‘has made the kindly light and the darkness, the kindly sleep and the
awaking;’7 at every step being suggested the father of the impure world, the
unkindly light, darkness or sleep.

The ecstasy which attended man’s first vision of an ideal life defied the
contradictory facts of outward and inward nature. So soon as he had beheld
a purer image of himself rising above his own animalism, he must not only
regard that animalism as an instigation of a devil, but also the like of it in
nature; and this conception will proceed pari passu with the creation of
pure deities in the image of that higher self. There was as yet no philosophy
demanding unity in the Cosmos, or forbidding man to hold as accursed so
much of nature as did not obviously accord with his ideals.

Mr. Edward B. Tylor has traced the growth of Animism from man’s shadow
and his breathing; Sir John Lubbock has traced the influence of dreams in
forming around him a ghostly world; Mr. Herbert Spencer has given an
analysis of the probable processes by which this invisible environment was
shaped for the mental conception in accordance with family and social
conditions. But it is necessary that we should here recognise the shadow
that walked by the moral nature, the breathings of religious aspiration, and
the dreams which visited a man whose moral sense was so generally at
variance with his animal desires. The code established for the common
good, while necessarily having a relation to every individual conscience, is
a restriction upon individual liberty. The conflict between selfishness and
duty is thus inaugurated; it continues in the struggle between the ‘law in the
members and the law in the spirit,’ which led Paul to beat his body
(ὑποπιαξομαί) to keep it in subjection; it passes from the Latin poet to the
Englishman, who turns his experience to a rune—

I see the right, and I approve it too;


Condemn the wrong, and yet the wrong pursue.

As the light which cast it was intense, even so intense was the shadow it
cast beneath all it could not penetrate. Passionate as was the saintliest man’s
love of good, even so passionate was his spiritual enemy’s love of evil.
High as was the azure vault that mingled with his dreams of purity, so deep
was the abyss beneath his lower nature. The superficial equalities of
phenomena, painful and pleasurable, to his animal nature had cast the
mould into which his theories of the inward and the moral phenomena must
be cast; and thus man—in an august moment—surrendered himself to the
dreadful conception of a supreme Principle of Wickedness: wherever good
was there stood its adversary; wherever truth, there its denier; no light
shone without the dark presence that would quench it; innocence had its
official accuser, virtue its accomplished tempter, peace its breaker, faith its
disturber and mocker. Nay, to this impersonation was added the last feature
of fiendishness, a nature which found its supreme satisfaction in ultimately
torturing human beings for the sins instigated by himself.

It is open to question how far any average of mankind really conceived this
theological dogma. Easy as it is to put into clear verbal statement; readily as
the analogies of nature supply arguments for and illustrations of a balance
between moral light and darkness, love and hatred; yet is man limited in
subjective conceptions to his own possibilities, and it may almost be said
that to genuinely believe in an absolute Fiend a man would have to be
potentially one himself. But any human being, animated by causeless and
purposeless desire to inflict pain on others, would be universally regarded
as insane, much more one who would without motive corrupt as well as
afflict.

Even theological statements of the personality of Evil, and what that


implies, are rare. The following is brave enough to be put on record, apart
from its suggestiveness.

‘It cannot be denied that as there is an inspiration of holy love, so is there an


inspiration of hatred, or frantic pleasure, with which men surrender
themselves to the impulses of destructiveness; and when the popular
language speaks of possessions of Satan, of incarnate devils, there lies at
the bottom of this the grave truth that men, by continued sinning, may pass
the ordinary limit between human and diabolic depravity, and lay open in
themselves a deep abyss of hatred which, without any mixture of self-
interest, finds its gratification in devastation and woe.’8

On this it may be said that the popular commentary on cases of the kind is
contained in the very phrase alluded to, ‘possession,’—the implication
being that such disinterested depravity is nowise possible within the range
of simple human experience,—and, in modern times, ‘possessions’ are
treated in asylums. Morbid conditions, however, are of such varied degrees
that it is probable many have imagined a Being in whom their worst
impulses are unrestrained, and thus there have been sufficient popular
approximations to an imaginative conception of a Devil to enable the
theological dogma, which few can analyse, to survive.

It must not be supposed, however, that the moral and spiritual ideals, to
which allusion has just been made, are normally represented in the various
Devils which we have to consider. It is the characteristic of personifications,
whether celestial or infernal, to supersede gradually the ideas out of which
they spring. As in the fable of Agni, who is said to have devoured his
parents when he was born, a metaphor of fire consuming the two sticks
which produce it, religious history shows both deities and devils, by the
flame of personal devotion or hatred they engender, burning up the ideas
that originate them. When instead of unconscious forces and inanimate laws
working to results called good and evil, men see great personal Wills
engaged in personal conflict, the universe becomes a government of
combat; the stars of heaven, the angels and the imps, men and women, the
very plants and animals, are caught up in the battle, to be marshalled on one
side or the other; and in the military spirit and fury of the struggle the
spiritual ideals become as insignificant beneath the phantom-hosts they
evoked as the violets and daisies which an army tramples in its march.
There is little difference at last between the moral characteristics of the
respective armies of Ormuzd and Ahriman, Michael and Satan; their
strategy and ferocity are the same.9 Wherever the conception is that of a
universe divided into hostile camps, the appropriate passions are kindled,
and in the thick of the field, where Cruelty and Gentleness met, is seen at
last a horned Beast confronted by a horned Lamb.10 On both sides is
exaltation of the horn.

We need only look at the outcome of the gentle and lowly Jesus through the
exigencies of the church militant to see how potent are such forces.
Although lay Christians of ordinary education are accustomed to rationalise
their dogmas as well as they can, and dwell on the loving and patient
characteristics of Jesus, the horns which were attached to the brow of him
who said, ‘Love your enemies’ by ages of Christian warfare remain still in
the Christ of Theology, and they are still depended on to overawe the
‘sinner.’ In an orthodox family with which I have had some acquaintance, a
little boy, who had used naughty expressions of resentment towards a
playmate was admonished that he should be more like Christ, ‘who never
did any harm to his enemies.’ ‘No,’ answered the wrathful child, ‘but he’s a-
going to.’

As in Demonology we trace the struggles of man with external obstructions,


and the phantasms in which these were reflected until they were understood
or surmounted, we have now to consider the forms which report human
progression on a higher plane,—that of social, moral, and religious
evolution. Creations of a crude Theology, in its attempt to interpret the
moral sentiment, the Devils to which we now turn our attention have
multiplied as the various interests of mankind have come into relations with
their conscience. Every degree of ascent of the moral nature has been
marked by innumerable new shadows cast athwart the mind and the life of
man. Every new heaven of ideas is followed by a new earth, but ere this
conformity of things to thoughts can take place struggles must come and the
old demons will be recalled for new service. As time goes on things new
grow old; the fresh issues pass away, their battlefields grow cold; then the
brood of superstition must flit away to the next field where carrion is found.
Foul and repulsive as are these vultures of the mind—organisms of moral
sewage—every one of them is a witness to the victories of mankind over
the evils they shadow, and to the steady advance of a new earth which
supplies them no habitat but the archæologist’s page.

1 ‘Treatise of Spirits.’ By John Beaumont, Gent. London, 1705.


2 Luke x. 19.
3 Rev. xii.
4 Rev. xii. cf. verses 4, 9 and 14.
5 Rev. xii. 12.
6 ‘Zendavesta,’ Yaçna xxx.; Max Müller, ‘Science of Religion,’ p. 238.
7 Yaçna xliii.
8 ‘Die Christliche Lehre von der Sünde.’ Von Julius Müller, Breslau, 1844, i. 193.
9 ‘Ormazd brought help to me; by the grace of Ormazd my troops entirely defeated the
rebel army and took Sitratachmes, and brought him before me. Then I cut off his nose and
his ears, and I scourged him. He was kept chained at my door. All the kingdom beheld him.
Afterwards I crucified him at Arbela.’ So says the tablet of Darius Hystaspes. But what
could Darius have done ‘by the grace of Ahriman’?
10 Cf. Rev. v. 6 and xii. 15.
Chapter II.
The Second Best.
Respect for the Devil—Primitive atheism—Idealisation—Birth of new gods—
New gods diabolised—Compromise between new gods and old—Foreign deities
degraded—Their utilisation.

A lady residing in Hampshire, England, recently said to a friend of the


present writer, both being mothers, ‘Do you make your children bow their
heads whenever they mention the Devil’s name? I do,’ she added solemnly,
—‘I think it’s safer.’

This instance of reverence for the Devil’s name, occurring in a respectable


English family, may excite a smile; but if my reader has perused the third
and fourth chapters (Part I.) of this work, in which it was necessary to state
certain facts and principles which underlie the phenomena of degradation in
both Demonology and Devil-lore, he will already know the high
significance of nearly all the names which have invested the
personifications of evil; and he will not be surprised to find their original
sanctity, though lowered, sometimes, surviving in such imaginary forms
after the battles in which they were vanquished have passed out of all
contemporary interest. If, for example, instead of the Devil, whose name is
uttered with respect in the Hampshire household, any theological bogey of
our own time were there mentioned, such as ‘Atheist,’ it might hardly
receive such considerate treatment.

The two chapters just referred to anticipate much that should be considered
at this point of our inquiry. It is only necessary here to supplement them
with a brief statement, and to some extent a recapitulation, of the processes
by which degraded deities are preserved to continue through a structural
development and fulfil a necessary part in every theological scheme which
includes the conception of an eternal difference between good and evil.

Every personification when it first appears expresses a higher and larger


view. When deities representing the physical needs of mankind have failed,
as they necessarily must, to meet those needs, atheism follows, though it
cannot for a long time find philosophical expression. It is an atheism ad
hoc, so to say, and works by degrading particular gods instead of by
constructing antitheistic theories. Successive dynasties of deities arise and
flourish in this way, each representing a less arbitrary relation to nature,—
peril lying in that direction,—and a higher moral and spiritual ideal, this
being the stronghold of deities. It is obvious that it is far easier to maintain
the theory that prayers are heard and answered by a deity if those prayers
are limited to spiritual requests, than when they are petitions for outward
benefits. By giving over the cruel and remorseless forces of nature to the
Devil,—i.e., to this or that personification of them who, as gods, had been
appealed to in vain to soften such forces,—the more spiritual god that
follows gains in security as well as beauty what he surrenders of empire and
omnipotence. This law, illustrated in our chapter on Fate, operates with
tremendous effect upon the conditions under which the old combat is
spiritualised.

An eloquent preacher has said:—‘Hawthorne’s fine fancy of the youth who


ascribed heroic qualities to the stone face on the brow of a cliff, thus
converting the rocky profile into a man, and, by dint of meditating on it
with admiring awe, actually transferred to himself the moral elements he
worshipped, has been made fact a thousand times, is made fact every day,
by earnest spirits who by faithful longing turn their visions into verities, and
obtain live answers to their petitions to shadows.’1

However imaginary may be the benedictions so derived by the worshipper


from his image, they are most real as they redound to the glory and power
of the image. The crudest personification, gathering up the sanctities of
generations, associated with the holiest hopes, the best emotions, the
profoundest aspirations of human nature, may be at length so identified
with these sentiments that they all seem absolutely dependent upon the
image they invest. Every criticism of such a personification then seems like
a blow aimed at the moral laws. If educated men are still found in
Christendom discussing whether morality can survive the overthrow of such
personifications, and whether life were worth living without them, we may
readily understand how in times when the social, ethical, and psychological
sciences did not exist at all, all that human beings valued seemed destined
to stand or fall with the Person supposed to be their only keystone.

But no Personage, however highly throned, can arrest the sun and moon, or
the mind and life of humanity. With every advance in physical or social
conditions moral elements must be influenced; every new combination
involves a recast of experiences, and presently of convictions. Henceforth
the deified image can only remain as a tyrant over the heart and brain which
have created it,—

Creatura a un tempo
E tiranno de l’uom, da cui soltanto
Ebbe nomi ed aspetti e regno e altari.2

This personification, thus ‘at once man’s creature and his tyrant,’ is
objectively a name. But as it has been invested with all that has been most
sacred, it is inevitable that any name raised against it shall be equally
associated with all that has been considered basest. This also must be
personified, for the same reason that the good is personified; and as names
are chiefly hereditary, it pretty generally happens that the title of some
fallen and discredited deity is advanced to receive the new anathema. But
what else does he receive? The new ideas; the growing ideals and the fresh
enthusiasms are associated with some fantastic shape with anathematised
name evoked from the past, and thus a portentous situation is reached. The
worshippers of the new image will not accept the bad name and its base
associations; they even grow strong enough to claim the name and altars of
the existing order, and give battle for the same. Then occurs the
demoralisation, literally speaking, of the older theology. The personification
reduced to struggle for its existence can no longer lay emphasis upon the
moral principles it had embodied, these being equally possessed by their
opponents; nay, its partisans manage to associate with their holy Name so
much bigotry and cruelty that the innovators are at length willing to resign
it. The personal loyalty, which is found to continue after loyalty to
principles has ceased, proceeds to degrade the virtues once reverenced
when they are found connected with a rival name. ‘He casteth out devils
through Beelzebub’ is a very ancient cry. It was heard again when Tertullian
said, ‘Satan is God’s ape.’ St. Augustine recognises the similarity between
the observances of Christians and pagans as proving the subtle
imitativeness of the Devil; the phenomena referred to are considered
elsewhere, but, in the present connection, it may be remarked that this
readiness to regard the same sacrament as supremely holy or supremely
diabolical as it is celebrated in honour of one name or another, accords
closely with the reverence or detestation of things more important than
sacraments, as they are, or are not, consecrated by what each theology
deems official sanction. When sects talk of ‘mere morality’ we may
recognise in the phrase the last faint war-cry of a god from whom the
spiritual ideal has passed away, and whose name even can survive only
through alliance with the new claimant of his altars. While the new gods
were being called devils the old ones were becoming such.

The victory of the new ideal turns the old one to an idol. But we are
considering a phase of the world when superstition must invest the new as
well as the old, though in a weaker degree. A new religious system prevails
chiefly through its moral superiority to that it supersedes; but when it has
succeeded to the temples and altars consecrated to previous divinities, when
the ardour of battle is over and conciliation becomes a policy as well as a
virtue, the old idol is likely to be treated with respect, and may not
impossibly be brought into friendly relation with its victorious adversary.
He may take his place as ‘the second best,’ to borrow Goethe’s phrase, and
be assigned some function in the new theologic régime. Thus, behind the
simplicity of the Hampshire lady instructing her children to bow at mention
of the Devil’s name, stretch the centuries in which Christian divines have as
warmly defended the existence of Satan as that of God himself. With
sufficient reason: that infernal being, some time God’s ‘ape’ and rival, was
necessarily developed into his present position and office of agent and
executioner under the divine government. He is the great Second Best; and
it is a strange hallucination to fancy that, in an age of peaceful inquiry, any
divine personification can be maintained without this patient Goat, who
bears blame for all the faults of nature, and who relieves divine Love from
the odium of supplying that fear which is the mother of devotion,—at least
in the many millions of illogical eyes into which priests can still look
without laughing.
Such, in brief outline, has been the interaction of moral and intellectual
forces operating within the limits of established systems, and of the nations
governed by them. But there are added factors, intensifying the forces on
each side, when alien are brought into rivalry and collision with national
deities. In such a contest, besides the moral and spiritual sentiments and the
household sanctities, which have become intertwined with the internal
deities, national pride is also enlisted, and patriotism. But on the other side
is enlisted the charm of novelty, and the consciousness of fault and failure
in the home system. Every system imported to a foreign land leaves behind
its practical shortcomings, puts its best foot forward—namely, its
theoretical foot—and has the advantage of suggesting a way of escape from
the existing routine which has become oppressive. Napoleon I. said that no
people profoundly attached to the institutions of their country can be
conquered; but what people are attached to the priestly system over them?
That internal dissatisfaction which, in secular government, gives welcome
to a dashing Corsican or a Prince of Orange, has been the means of
introducing many an alien religion, and giving to many a prophet the
honour denied him in his own country. Buddha was a Hindu, but the
triumph of his religion is not in India; Zoroaster was a Persian, but there are
no Parsees in Persia; Christianity is hardly a colonist even in the native land
of Christ.

These combinations and changes were not effected without fierce


controversies, ferocious wars, or persecutions, and the formation of many
devils. Nothing is more normal in ancient systems than the belief that the
gods of other nations are devils. The slaughter of the priests of Baal
corresponds with the development of their god into Beelzebub. In
proportion to the success of Olaf in crushing the worshippers of Odin, their
deity is steadily transformed to a diabolical Wild Huntsman. But here also
the forces of partial recovery, which we have seen operating in the outcome
of internal reform, manifest themselves; the vanquished, and for a time
outlawed deity, is, in many cases, subsequently conciliated and given an
inferior, and, though hateful, a useful office in the new order. Sometimes,
indeed, as in the case of the Hindu destroyer Siva, it is found necessary to
assign a god, anathematised beyond all power of whitewash, to an equal
rank with the most virtuous deity. Political forces and the exigencies of
propagandism work many marvels of this kind, which will meet us in the
further stages of our investigation.

Every superseded god who survives in subordination to another is pretty


sure to be developed into a Devil. Euphemism may tell pleasant fables
about him, priestcraft may find it useful to perpetuate belief in his
existence, but all the evils of the universe, which it is inconvenient to
explain, are gradually laid upon him, and sink him down, until nothing is
left of his former glory but a shining name.

1 ‘Prayer and Work.’ By Octavius B. Frothingham. New York, 1877.


2 ‘Lucifero, Poema di Mario Rapisardi.’ Milano, 1877.
Chapter III.
Ahriman: The Divine Devil.
Mr. Irving’s impersonation of Superstition—Revolution against pious privilege—
Doctrine of ‘merits’—Saintly immorality in India—A Pantheon turned Inferno—
Zendavesta on Good and Evil—Parsî Mythology—The Combat of Ahriman with
Ormuzd—Optimism—Parsî Eschatology—Final Restoration of Ahriman.

Any one who has witnessed Mr. Henry Irving’s scholarly and masterly
impersonation of the character of Louis XI. has had an opportunity of
recognising a phase of superstition which happily it were now difficult to
find off the stage. Nothing could exceed the fine realism with which that
artist brought before the spectator the perfected type of a pretended religion
from which all moral features have been eliminated by such slow processes
that the final success is unconsciously reached, and the horrible result
appears unchecked by even any affectation of actual virtue. We see the king
at sound of a bell pausing in his instructions for a treacherous assassination
to mumble his prayers, and then instantly reverting to the villany over
whose prospective success he gloats. In the secrecy of his chamber no mask
falls, for there is no mask; the face of superstition and vice on which we
look is the real face which the ages of fanaticism have transmitted to him.

Such a face has oftener been that of a nation than that of an individual, for
the healthy forces of life work amid the homes and hearts of mankind long
before their theories are reached and influenced. Such a face it was against
which the moral insurrection which bears the name of Zoroaster arose,
seeing it as physiognomy of the Evil Mind, naming it Ahriman, and, in the
name of the conscience, aiming at it the blow which is still felt across the
centuries.

Ingenious theorists have accounted for the Iranian philosophy of a universal


war between Ormuzd (Ahuramazda) the Good, and Ahriman
(Angromainyus) the Evil, by vast and terrible climatic changes, involving
extremes of heat and cold, of which geologists find traces about Old Iran,
from which a colony of Aryans migrated to New Iran, or Persia. But
although physical conditions of this character may have supplied many of
the metaphors in which the conflict between Good and Evil is described in
the Avesta, there are other characteristics of that ancient scripture which
render it more probable that the early colonisation of Persia was, like that of
New England, the result of a religious struggle. Some of the gods most
adored in India reappear as execrated demons in the religion of Zoroaster;
the Hindu word for god is the Parsî word for devil. These antagonisms are
not merely verbal; they are accompanied in the Avesta with the most furious
denunciations of theological opponents, whom it is not difficult to identify
with the priests and adherents of the Brahman religion.

The spirit of the early scriptures of India leaves no room for doubt as to the
point at which this revolution began. It was against pious Privilege. The
saintly hierarchy of India were a caste quite irresponsible to moral laws.
The ancient gods, vague names for the powers of nature, were strictly
limited in their dispensations to those of their priests;1 and as to these
priests the chief necessities were ample offerings, sacrifices, and fulfilment
of the ceremonial ordinances in which their authority was organised, these
were the performances rewarded by a reciprocal recognition of authority. To
the image of this political régime, theology, always facile, accommodated
the regulations of the gods. The moral law can only live by being supreme;
and as it was not supreme in the Hindu pantheon, it died out of it. The
doctrine of ‘merits,’ invented by priests purely for their own power,
included nothing meritorious, humanly considered; the merits consisted of
costly sacrifices, rich offerings to temples, tremendous penances for
fictitious sins, ingeniously devised to aggrandise the penances which
disguised power, and prolonged austerities that might be comfortably
commuted by the wealthy. When this doctrine had obtained general
adherence, and was represented by a terrestrial government corresponding
to it, the gods were necessarily subject to it. That were only to say that the
powers of nature were obedient to the ‘merits’ of privileged saints; and from
this it is an obvious inference that they are relieved from moral laws
binding on the vulgar.

The legends which represent this phase of priestly dominion are curiously
mixed. It would appear that under the doctrine of ‘merits’ the old gods
declined. Such appears to be the intimation of the stories which report the
distress of the gods through the power of human saints. The Rajah Ravana
acquired such power that he was said to have arrested the sun and moon,
and so oppressed the gods that they temporarily transformed themselves to
monkeys in order to destroy him. Though Viswámitra murders a saint, his
merits are such that the gods are in great alarm lest they become his
menials; and the completeness, with which moral considerations are left out
of the struggle on both sides is disclosed in the item that the gods
commissioned a nymph to seduce the saintly murderer, and so reduce a little
the force of his austerities. It will be remembered that the ancient struggle
of the Devas and Asuras was not owing to any moral differences, but to an
alleged unfair distribution of the ambrosia produced by their joint labours in
churning the ocean. The fact that the gods cheated the demons on that
occasion was never supposed to affect the supremacy they acquired by the
treachery; and it could, therefore, cause no scandal when later legends
reported that the demons were occasionally able to take gods captive by the
practice of these wonderful ‘merits’ which were so independent of morals.
One Asura is said to have gained such power in this way that he subjugated
the gods, and so punished them that Siva, who had originally endowed that
demon, called into being Scanda, a war-god, to defend the tortured deities.
The most ludicrous part of all is that the gods themselves were gradually
reduced to the necessity of competing like others for these tremendous
powers; thus the Bhagavat Purana states that Brahma was enabled to create
the universe by previously undergoing penance for sixteen thousand years.

The legends just referred to are puranic, and consequently of much later
date than the revolution traceable in the Iranian religion; but these later
legends are normal growths from vedic roots. These were the principles of
ancient theology, and the foundation of priestly government. In view of
them we need not wonder that Hindu theology devised no special devil;
almost any of its gods might answer the purposes of one. Nor need we be
surprised that it had no particular hell; any society organised by the
sanctions of religion, but irresponsible to its moral laws, would render it
unnecessary to look far for a hell.
From this cosmological chaos the more intelligent Hindus were of course
liberated; but the degree to which the fearful training had corrupted the
moral tissues of those who had been subjected to it was revealed in the bald
principle of their philosophers, that the superstition must continue to be
imposed on the vulgar, whilst the learned might turn all the gods into a
scientific terminology.

The first clear and truthful eye that touched that system would transform it
from a Heaven to an Inferno. So was it changed under the eye of Zoroaster.
That ancient pantheon which had become a refuge for all the lies of the
known world; whose gods were liars and their supporters liars; was now
turned into a realm of organised disorder, of systematised wrong; a vast
creation of wickedness, at whose centre sat its creator and inspirer, the
immoral god, the divine devil—Ahriman.

It is indeed impossible to ascertain how far the revolt against the old
Brahmanic system was political. It is, of course, highly improbable that any
merely speculative system would excite a revolution; but at the same time it
must be remembered that, in early days, an importance was generally
attached to even abstract opinions such as we still find among the
superstitious who regard an atheistic sentiment as worse than a theft.
However this may have been, the Avesta does not leave us in any doubt as
to the main fact,—namely, that at a certain time and place man came to a
point where he had to confront antagonism to fundamental moral principles,
and that he found the so-called gods against him. In the establishment of
those principles priests recognised their own disestablishment. What those
moral laws that had become necessary to society were is also made clear.
‘We worship the Pure, the Lord of Purity!’ ‘We honour the good spirit, the
good kingdom, the good law,—all that is good.’ ‘Evil doctrine shall not
again destroy the world.’ ‘Good is the thought, good the word, good the
deed, of the pure Zarathustra.’ ‘In the beginning the two heavenly Ones
spoke—the Good to the Evil—thus: Our souls, doctrines, words, works, do
not unite together.’ These sentences are from the oldest Gâthâs of the
Avesta.
The following is a very ancient Gâthâ:—‘All your Devas (Hindu ‘gods’) are
only manifold children of the Evil Mind, and the great One who worships
the Saoma of lies and deceits; besides the treacherous acts for which you
are notorious in the Seven Regions of the earth. You have invented all the
evil that men speak and do, which is indeed pleasant to the Devas, and is
devoid of all goodness, and therefore perishes before the insight of the truth
of the wise. Thus you defraud men of their good minds and of their
immortality by your evil minds—as well by those of the Devas as through
that of the Evil Spirit—through evil deeds and evil words, whereby the
power of liars grows.

‘1. Come near, and listen to the wise sayings of the omniscient, the songs in
praise of the Living One, and the prayers of the Good Spirit, the glorious
truths whose origin is seen in the flames.

‘2. Listen, therefore, to the Earth spirit—Look at the flames with reverent
mind. Every one, man and woman, is to be distinguished according to his
belief. Ye ancient Powers, watch and be with us!

‘3. From the beginning there were two Spirits, each active in itself. They are
the good and the bad in thought, word, and deed. Choose ye between them:
do good, not evil!

‘4. And these two Spirits meet and create the first existence, the earthy, that
which is and that which is not, and the last, the spiritual. The worst
existence is for the liars, the best for the truthful.

‘5. Of these two spirits choose ye one, either the lying, the worker of Evil,
or the true holiest spirit. Whoso chooses the first chooses the hardest fate;
whoso the last, honours Ahuramazda in faith and in truth by his deeds.

‘6. Ye cannot serve both of these two. An evil spirit whom we will destroy
surprises those who deliberate, saying, Choose the Evil Mind! Then do
those spirits gather in troops to attack the two lives of which the prophets
prophesy.
‘7. And to this earthly life came Armaiti with earthly power to help the
truth, and the good disposition: she, the Eternal, created the material world,
but the Spirit is with thee, O Wise One! the first of creations in time.

‘8. When any evil falls upon the spirit, thou, O Wise One, givest temporal
possessions and a good disposition; but him whose promises are lies, and
not truth, thou punishest.’

Around the hymns of the Avesta gradually grew a theology and a


mythology which were destined to exert a powerful influence on the world.
These are contained in the Bundehesch.2 Anterior to all things and all
beings was Zeruane-Akrene (‘Boundless Time’), so exalted that he can only
be worshipped in silence. From him emanated two Ferouers, spiritual types,
which took form in two beings, Ormuzd and Ahriman. These were equally
pure; but Ahriman became jealous of his first-born brother, Ormuzd. To
punish Ahriman for his evil feeling, the Supreme Being condemned him to
12,000 years’ imprisonment in an empire of rayless Darkness. During that
period must rage the conflict between Light and Darkness, Good and Evil.
As Ormuzd had his pre-existing type or Ferouer, so by a similar power—
much the same as the Platonic Logos or Word—he created the pure or
spiritual world, by means of which the empire of Ahriman should be
overthrown. On the earth (still spiritual) he raised the exceeding high
mountain Albordj, Elburz (snow mountain),3 on whose summit he fixed his
throne; whence he stretched the bridge Chinevat, which, passing directly
over Duzhak, the abyss of Ahriman (or hell), reaches to the portal of
Gorodman, or heaven. All this was but a Ferouer world—a prototype of the
material world. In anticipation of its incorporation in a material creation,
Ormuzd (by emanations) created in his own image six Amshaspands, or
agents, of both sexes, to be models of perfection to lower spirits—and to
mankind, when they should be created—and offer up their prayers to
himself. The second series of emanations were the Izeds, benevolent genii
and guardians of the world, twenty-eight in number, of whom the chief is
Mithras, the Mediator. The third series of emanations were the innumerable
Ferouers of things and men—for each must have its soul, which shall purify
them in the day of resurrection. In antagonism to all these, Ahriman
produced an exactly similar host of dark and evil powers. These Devas rise,
rank on rank, to their Arch-Devs—each of whom is chained to his planet—
and their head is Ash-Mogh, the ‘two-footed serpent of lies,’ who seems to
correspond to Mithras, the divine Mediator.

After a reign of 3000 years Ormuzd entered on the work of realising his
spiritual emanations in a material universe. He formed the sun as
commander-in-chief, the moon as his lieutenant, the planets as captains of a
great host—the stars—who were soldiers in his war against Ahriman. The
dog Sirius he set to watch at the bridge Chinevat (the Milky Way), lest
thereby Ahriman should scale the heavens. Ormuzd then created earth and
water, which Ahriman did not try to prevent, knowing that darkness was
inherent in these. But he struck a blow when life was produced. This was in
form of a Bull, and Ahriman entered it and it perished; but on its destruction
there came out of its left shoulder the seed of all clean and gentle animals,
and, out of its right shoulder—Man.

Ahriman had matched every creation thus far; but to make man was beyond
his power, and he had no recourse but to destroy him. However, when the
original man was destroyed, there sprang from his body a tree which bore
the first human pair, whom Ahriman, however, corrupted in the manner
elsewhere described.

It is a very notable characteristic of this Iranian theology, that although the


forces of good and evil are co-extensive and formally balanced, in potency
they are not quite equal. The balance of force is just a little on the side of
the Good Spirit. And this advantage appears in man. Zoroaster said, ‘No
earthly man with a hundredfold strength does so much evil as Mithra with
heavenly strength does good;’ and this thought reappears in the Parsî belief
that the one part of paradisiac purity, which man retained after his fall,
balances the ninety-nine parts won by Ahriman, and in the end will redeem
him. For this one divine ray preserved enables him to receive and obey the
Avesta, and to climb to heaven by the stairway of three vast steps—pure
thought, pure word, pure deed. The optimistic essence of the mythology is
further shown in the belief that every destructive effort of Ahriman resulted
in a larger benefit than Ormuzd had created. The Bull (Life) destroyed, man
and animal sprang into being; the man destroyed, man and woman
appeared. And so on to the end. In the last quarter of the 12,000 years for
which Ahriman was condemned, he rises to greater power even than
Ormuzd, and finally he will, by a fiery comet, set the visible universe in
conflagration; but while this scheme is waxing to consummation Ormuzd
will send his holy Prophet Sosioch, who will convert mankind to the true
law,4 so that when Ahriman’s comet consumes the earth he will really be
purifying it. Through the vast stream of melted metals and minerals the
righteous shall pass, and to them it will be as a bath of warm milk: the
wicked in attempting to pass shall be swept into the abyss of Duzhak;
having then suffered three days and nights, they shall be raised by Ormuzd
refined and purified. Duzhak itself shall be purified by this fire, and last of
all Ahriman himself shall ascend to his original purity and happiness. Then
from the ashes of the former world shall bloom a paradise that shall remain
for ever.

In this system it is notable that we find the monster serpent of vedic


mythology, Ahi, transformed into an infernal region, Duzhak. The dragon,
being a type of physical suffering, passes away in Iranian as in the later
Semitic mythology before the new form, which represents the stings of
conscience though it may be beneath external pleasure. In this respect,
therefore, Ahriman fulfils the definition of a devil already given. In the
Avesta he fulfils also another condition essential to a devil, the love of evil
in and for itself. But in the later theology it will be observed that evil in
Ahriman is not organic. The war being over and its fury past, the hostile
chief is seen not so black as he had been painted; the belief obtains that he
does not actually love darkness and evil. He was thrust into them as a
punishment for his jealousy, pride, and destructive ambition. And because
that dark kingdom was a punishment—therefore not congenial—it was at
length (the danger past) held to be disciplinary. Growing faith in the real
supremacy of Good discovers the immoral god to be an exaggerated
anthropomorphic egoist; this divine devil is a self-centred potentate who
had attempted to subordinate moral law and human welfare to his personal
ascendancy. His fate having sealed the sentence on all ambitions of that
character, humanity is able to pardon the individual offender, and find a
hope that Ahriman, having learned that no real satisfaction for a divine
nature can be found in mere power detached from rectitude, will join in the
harmony of love and loyalty at last.

1 E quanto ebbe e mantiene a l’uom soltanto


Il deve, a l’uom che d’oqui sue destino
O prospero, o maligno, arbitro e solo.
‘Whatever he (God) had, he owed to man alone, to man who, for good or ill, is sole arbiter
of his own fate.’—Rapisardi’s Lucifero.
2 The following abridgment mainly follows that of James Freeman Clarke in his ‘Ten
Great Religions.’
3 White or Snowy Mountain. Cf. Alp, Elf, &c.
4 ‘Elias shall first come and restore all things.’
Chapter IV.
Viswámitra: The Theocratic Devil.
Priestcraft and Pessimism—An Aryan Tetzel and his Luther—Brahman Frogs—
Evolution of the sacerdotal Saint—Viswámitra the Accuser of Virtue—The Tamil
Passion-play ‘Hariśchandra’—Ordeal of Goblins—The Martyr of Truth—Virtue
triumphant over ceremonial ‘merits’—Hariśchandra and Job.

Priestcraft in government means pessimism in the creed and despair in the


heart. Under sacerdotal rule in India it seemed paradise enough to leave the
world, and the only hell dreaded was a return to it. ‘The twice-born man,’
says Manu, ‘who shall without intermission have passed the time of his
studentship, shall ascend after death to the most exalted of regions, and no
more spring to birth again in this lower world.’ Some clause was necessary
to keep the twice-born man from suicide. Buddha invented a plan of
suicide-in-life combined with annihilation of the gods, which was driven
out of India because it put into the minds of the people the philosophy of
the schools. Thought could only be trusted among classes interested to
conceal it.

The power and authority of a priesthood can only be maintained on the


doctrine that man is ‘saved’ by the deeds of a ceremonial law; any general
belief that morality is more acceptable to gods than ceremonies must be
fatal to those occult and fictitious virtues which hedge about every pious
impostor. Sacerdotal power in India depended on superstitions carefully
fostered concerning the mystical properties of a stimulating juice (soma),
litanies, invocations, and benedictions by priests; upon sacrifices to the
gods, including their priests, austerities, penances, pilgrimages, and the like;
one characteristic running through all the performances—their utter
worthlessness to any being in the universe except the priest. An artificial
system of this kind has to create its own materials, and evoke forces of
evolution from many regions of nature. It is a process requiring much more
than the wisdom of the serpent and more than its harmfulness; and there is a
bit of nature’s irony in the fact that when the Brahman Rishi gained
supremacy, the Cobra was also worshipped as belonging to precisely the
same caste and sanctity.

There are traces of long and fierce struggles preceding this consummation.
Even in the Vedic age—in the very dawn of religious history—Tetzel
appears with his indulgences and Luther confronts him. The names they
bore in ancient India were Viswámitra and Vasishtha. Both of these were
among the seven powerful Rishis who made the hierarchy of India in the
earliest age known to us. Both were composers of some of the chief hymns
of the Vedas, and their respective hymns bear the stamp of the sacerdotal
and the anti-sacerdotal parties which contended before the priestly sway
had reached its complete triumph. Viswámitra was champion of the high
priestly party and its political pretensions. In the Rig-Veda there are forty
hymns ascribed to him and his family, nearly all of which celebrate the
divine virtues of Soma-juice and the Soma-sacrifice. As the exaltation of
the priestly caste in Israel was connected with a miracle, in which the
Jordan stopped flowing till the ark had been carried over, so the rivers
Sutledge and Reyah were said to have rested from their course when
Viswámitra wished to cross them in seeking the Soma. This Rishi became
identified in the Hindu mind for all time with political priestcraft. On the
other hand, Vasishtha became equally famous for his hostility to that power,
as well as for his profoundly religious character,—the finest hymns of the
Vedas, as to moral feeling, being those that bear his name. The anti-
sacerdotal spirit of Vasishtha is especially revealed in a strange satirical
hymn in which he ridicules the ceremonial Bráhmans under the guise of a
panegyric on frogs. In this composition occur such verses as these:—

‘Like Bráhmans at the Soma-sacrifice of Atirâtra, sitting round a full pond


and talking, you, O frogs, celebrate this day of the year when the rainy
season begins.

‘These Bráhmans, with their Soma, have had their say, performing the
annual rite. These Adhwaryus, sweating while they carry the hot pots, pop
out like hermits.
‘They have always observed the order of the gods as they are to be
worshipped in the twelvemonth; these men do not neglect their season....

‘Cow-noise gave, Goat-noise gave, the Brown gave, and the Green gave us
treasures. The frogs, who give us hundreds of cows, lengthened our life in
the rich autumn.’1

Viswámitra and Vasishtha appear to have been powerful rivals in seeking


the confidence of King Sudás, and from their varying fortunes came the
tremendous feud between them which plays so large a part in the traditions
of India. The men were both priests, as are both ritualists and broad-
churchmen in the present day. They were borne on the stream of mythologic
evolution to representative regions very different from any they could have
contemplated. Vasishtha, ennobled by the moral sentiment of ages, appears
as the genius of truth and justice, maintaining these as of more ‘merit’ than
any ceremonial perfections. The Bráhmans, whom he once ridiculed, were
glad enough in the end to make him their patron saint, though they did not
equally honour his principles. On the other hand, Viswámitra became the
type of that immoral divinity which received its Iranian anathema in
Ahriman. The murder he commits is nothing in a personage whose Soma-
celebrations have raised him so high above the trivialities of morality.

It is easy to see what must be the further development of such a type as


Viswámitra when he shall have passed from the guarded pages of puranic
tradition to the terrible simplicities of folklore. The saint whose majesty is
built on ‘merits,’ which have no relation to what the humble deem virtues,
naturally holds such virtues in cynical contempt; naturally also he is
indignant if any one dares to suggest that the height he has reached by
costly and prolonged observances may be attained by poor and common
people through the practice of virtue. The next step is equally necessary.
Since it is hard to argue down the facts of human nature, Vasishtha is pretty
sure to have a strong, if sometimes silent, support for his heretical theory of
a priesthood representing virtue; consequently Viswámitra will be reduced
at length to deny the existence of virtue, and will become the Accuser of
those to whom virtues are attributed. Finally, from the Accuser to the
Tempter the transition is inevitable. The public Accuser must try and make
good his case, and if the facts do not support it, he must create other facts
which will, or else bear the last brand of his tribe—Slanderer.

Leaving out of sight all historical or probable facts concerning Viswámitra


and Vasishtha, but remembering the spirit of them, let us read the great
Passion-play of the East, in which their respective parts are performed again
as intervening ages have interpreted them. The hero of this drama is an
ancient king named Hariśchandra, who, being childless, and consequently
unable to gain immortality, promised the god Varuna to sacrifice to him a
son if one were granted him. The son having been born, the father
beseeches Varuna for respite, which is granted again and again, but stands
firmly by his promise, although it is finally commuted. The repulsive
features of the ancient legend are eliminated in the drama, the promise now
being for a vast sum of money which the king cannot pay, but which
Viswámitra would tempt him to escape by a technical fiction. Sir Mutu
Cumára Swámy, whose translation I follow, presents many evidences of the
near relation in which this drama stands to the religious faith of the people
in Southern India and parts of Ceylon, where its representation never fails
to draw vast crowds from every part of the district in which it may occur,
the impression made by it being most profound.2

We are first introduced to Hariśchandra, King of Ayòdiah (Oude), in his


palace, surrounded by every splendour, and by the devotion of his
prosperous people. His first word is an ascription to the ‘God of gods.’ His
ministers come forward and recount the wealth and welfare of the nation.
The first Act witnesses the marriage of Hariśchandra with the beautiful
princess Chandravatí, and it closes with the birth of a son.

The second Act brings us into the presence of Indra in the Abode of the
Gods. The Chief enters the Audience Hall of his palace, where an assembly
of deities and sages has awaited him. These sages are holy men who have
acquired supernatural power by their tremendous austerities; and of these
the most august is Viswámitra. By the magnitude and extent of his
austerities he has gained a power beyond even that of the Triad, and can
reduce the worlds to cinders. All the gods court his favour. As the Council
proceeds, Indra addresses the sages—‘Holy men! as gifted with
supernatural attributes, you roam the universe with marvellous speed, there
is no place unknown to you. I am curious to learn who, in the present times,
is the most virtuous sovereign on the earth below. What chief of mortals is
there who has never told a lie—who has never swerved from the course of
justice?’ Vasishtha, a powerful sage and family-priest of Hariśchandra,
declares that his royal disciple is such a man. But the more powerful
Viswámitra denounces Hariśchandra as cruel and a liar. The quarrel
between the two Rishis waxes fierce, until Indra puts a stop to it by
deciding that an experiment shall be made on Hariśchandra. Vasishtha
agrees that if his disciple can be shown to have told a lie, or can be made to
tell one, the fruit of his life-long austerities, and all the power so gained,
shall be added to Viswámitra; while the latter must present his opponent
with half of his ‘merits’ if Hariśchandra be not made to swerve from the
truth. Viswámitra is to employ any means whatever, neither Indra or any
other interfering.

Viswámitra sets about his task of trying and tempting Hariśchandra by


informing that king that, in order to perform a sacrifice of special
importance, he has need of a mound of gold as high as a missile slung by a
man standing on an elephant’s back. With the demand of so sacred a being
Hariśchandra has no hesitation in complying, and is about to deliver the
gold when Viswámitra requests him to be custodian of the money for a
time, but perform the customary ceremony of transfer. Holding
Hariśchandra’s written promise to deliver the gold whensoever demanded,
Viswámitra retires with compliments. Then wild beasts ravage
Hariśchandra’s territory; these being expelled, a demon boar is sent, but is
vanquished by the monarch. Viswámitra then sends unchaste dancing-girls
to tempt Hariśchandra; and when he has ordered their removal, Viswámitra
returns with them, and, feigning rage, accuses him of slaying innocent
beasts and of cruelty to the girls. He declares that unless Hariśchandra
yields to the Pariah damsels, he himself shall be reduced to a Pariah slave.
Hariśchandra offers all his kingdom and possessions if the demand is
withdrawn, absolutely refusing to swerve from his virtue. This Viswámitra
accepts, is proclaimed sovereign of Ayòdiah, and the king goes forth a
beggar with his wife and child. But now, as these are departing, Viswámitra
demands that mound of gold which was to be paid when called for. In vain
Hariśchandra pleads that he has already delivered up all he possesses, the
gold included; the last concession is declared to have nothing to do with the
first. Yet Viswámitra says he will be charitable; if Hariśchandra will simply
declare that he never pledged the gold, or, having done so, does not feel
bound to pay it, he will cancel that debt. ‘Such a declaration I can never
make,’ replies Hariśchandra. ‘I owe thee the gold, and pay it I shall. Let a
messenger accompany me and leave me not till I have given him thy due.’

From this time the efforts of Viswámitra are directed to induce


Hariśchandra to declare the money not due. Amid his heartbroken people—
who cry, ‘Where are the gods? Can they tolerate this?’—he who was just
now the greatest and happiest monarch in the world goes forth on the
highway a wanderer with his Chandravatí and their son Devaráta dressed in
coarsest garments. His last royal deed is to set the crown on his tempter’s
head. The people and officers follow, and beg his permission to slay
Viswámitra, but he rebukes them, and counsels submission. Viswámitra
orders a messenger, Nakshatra, to accompany the three wretched ones, and
inflict the severest sufferings on them until the gold is paid, and amid each
ordeal to offer Hariśchandra all his former wealth and happiness if he will
utter a falsehood.

They come to a desert whose sands are so hot that the wife faints.
Hariśchandra bears his son in his arms, but in addition is compelled to bear
Nakshatra (the Bráhman and tormentor) on his shoulders. They so pass
amid snakes and scorpions, and receive terrible stings; they pass through
storm and flood, and yet vainly does Nakshatra suggest the desired
falsehood.

Then follows the ordeal of Demons, which gives an interesting insight into
Tamil Demonology. One of the company exclaims—‘How frightful they
look! Who can face them? They come in battalions, young and old, small
and great—all welcome us. They disport themselves with a wild dance;
flames shoot from their mouths; their feet touch not the earth; they move in
the air. Observe you the bleeding corpses of human beings in their hands.
They crunch them and feed on the flesh. The place is one mass of gore and
filth. Wolves and hyænas bark at them; jackals and dogs follow them. They
are near. May Siva protect us!’

Nakshatra. How dreadful! Hariśchandra, what is this? Look! evil demons


stare at me—I tremble for my life. Protect me now, and I ask you no more
for the gold.

Hariśchandra. Have no fear, Nakshatra. Come, place thyself in the midst


of us.

Chief of the Goblins. Men! little men! human vermin! intrude ye thus into
my presence? Know that, save only the Bráhman standing in the midst of
you, you are all my prey to-night.

Hariśchandra. Goblin! certainly thou art not an evil-doer, for thou hast
excepted this holy Bráhman. As for ourselves, we know that the bodies
which begin to exist upon earth must also cease to exist on it. What matters
it when death comes? If he spares us now he reserves us only for another
season. Good, kind demon! destroy us then together; here we await our
doom.

Nakshatra. Hariśchandra! before you thus desert me, make the goblin
promise you that he will not hurt me.

Hariśchandra. Thou hast no cause for alarm; thou art safe.

Chief of the Goblins. Listen! I find that all four of you are very thin; it is
not worth my while to kill you. On examining closely, I perceive that the
young Bráhman is plump and fat as a wild boar. Give him up to me—I want
not the rest.

Nakshatra. O Gods! O Hariśchandra! you are a great monarch! Have


mercy on me! Save me, save me! I will never trouble you for the gold, but
treat you considerately hereafter.

Hariśchandra. Sir, thy life is safe, stand still.


Nakshatra. Allow me, sirs, to come closer to you, and to hold you by the
hand (He grasps their hands.)

Hariśchandra. King of the Goblins! I address thee in all sincerity; thou


wilt confer on us a great favour indeed by despatching us speedily to the
Judgment Hall of the God of Death. The Bráhman must not be touched;
devour us.

The Goblin (grinding his teeth in great fury). What! dare you disobey me?
Will you not deliver the Bráhman?

Hariśchandra. No, we cannot. We alone are thy victims.

[Day breaks, and the goblins disappear.]

Having thus withstood all temptation to harm his enemy, or to break a


promise he had given to treat him kindly, Hariśchandra is again pressed for
the gold or the lie, and, still holding out, an ordeal of fire follows. Trusting
the God of Fire will cease to afflict if one is sacrificed, Hariśchandra
prepares to enter the conflagration first, and a pathetic contention occurs
between him and his wife and son as to which shall be sacrificed. In the end
Hariśchandra rushes in, but does not perish.

Hariśchandra is hoping to reach the temple of Vis Wanàth3 at Kasi and


invoke his aid to pay the gold. To the temple he comes only to plead in vain,
and Nakshatra tortures him with instruments. Finally Hariśchandra, his wife
and child, are sold as slaves to pay the debt. But Viswámitra, invisibly
present, only redoubles his persecutions. Hariśchandra is subjected to the
peculiar degradation of having to burn dead bodies in a cemetery.
Chandravatí and her son are subjected to cruelties. The boy is one day sent
to the forest, is bitten by a snake, and dies. Chandravatí goes out in the
night to find the body. She repairs with it to the cemetery. In the darkness
she does not recognise her husband, the burner of the bodies, nor he his
wife. He has strictly promised his master that every fee shall be paid, and
reproaches the woman for coming in the darkness to avoid payment.
Chandravatí offers in payment a sacred chain which Siva had thrown round
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

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

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookname.com

You might also like