Programming With C 3rd Edition Ravichandran pdf download
Programming With C 3rd Edition Ravichandran pdf download
download
https://ebookname.com/product/programming-with-c-3rd-edition-
ravichandran/
https://ebookname.com/product/programming-problem-solving-
abstraction-with-c-moffat/
https://ebookname.com/product/windows-forms-programming-
with-c-1st-edition-erik-brown/
https://ebookname.com/product/object-oriented-programming-
with-c-4th-edition-e-balagurusamy/
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/
https://ebookname.com/product/latin-american-novels-of-the-
conquest-reinventing-the-new-world-1st-edition-kimberle-s-lopez/
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/
https://ebookname.com/product/pro-html5-and-css3-design-
patterns-1st-edition-michael-bowers/
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
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.
Vice President and Managing Director—McGraw-Hill Education: Asia Pacific Region: Ajay Shukla
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
RQXCRRQZDLCZL
Dedicated to my son
Suseekaran
for his love and support
Contents
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
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.
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.
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:
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.
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++
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.
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.
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.
‘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
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—
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.
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.’
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.
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.
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.
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.’
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.
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:—
‘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
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.
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!’
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.
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.
The Goblin (grinding his teeth in great fury). What! dare you disobey me?
Will you not deliver the Bráhman?
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.
ebookname.com