100% found this document useful (3 votes)
120 views84 pages

Ebooks File Programming With C 3rd Edition Ravichandran All Chapters

ebook

Uploaded by

kakenasbae
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 (3 votes)
120 views84 pages

Ebooks File Programming With C 3rd Edition Ravichandran All Chapters

ebook

Uploaded by

kakenasbae
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/ 84

Full download ebook at ebookname.

com

Programming With C 3rd Edition Ravichandran

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

OR CLICK BUTTON

DOWLOAD NOW

Download more ebook from https://ebookname.com


More products digital (pdf, epub, mobi) instant
download maybe you interests ...

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/

Effective Robotics Programming with ROS 3rd Edition


Anil Mahtani

https://ebookname.com/product/effective-robotics-programming-
with-ros-3rd-edition-anil-mahtani/
Programming in Visual C 2008 3rd Edition Julia Case
Bradley

https://ebookname.com/product/programming-in-visual-c-2008-3rd-
edition-julia-case-bradley-2/

Programming in Visual C 2008 3rd Edition Julia Case


Bradley

https://ebookname.com/product/programming-in-visual-c-2008-3rd-
edition-julia-case-bradley/

System Programming with C and Unix 1st Edition Adam


Hoover

https://ebookname.com/product/system-programming-with-c-and-
unix-1st-edition-adam-hoover/

An Introduction to Programming with C 8th Edition Diane


Zak

https://ebookname.com/product/an-introduction-to-programming-
with-c-8th-edition-diane-zak/

Android Programming In Java Starting with an App 3rd


Edition James

https://ebookname.com/product/android-programming-in-java-
starting-with-an-app-3rd-edition-james/
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.
4 Programming with C++

An object has three characteristics:


∑ name
∑ state
∑ behaviour
(a) Name It is a unique identity for representing an object of
a class.
(b) State It is a representation of attributes by internal data
structures.
(c) Behaviour It is a set of allowed operations, functions and
methods. Fig. 1.3(a) UML object Diagram for
An object communicates with another by passing messages the Class Student_info
using some protocols.

1.5.2 Class
A class is a template for constructing objects (Fig. 1.3(a) & (b)).
Objects are instances of a class, i.e., specific occurrences of a
class. Once a class is defined, any number of objects of that
class are easily created. The code or class implementation (or
class body) contains the definition of each method (member Fig. 1.3(b) UML Class and Object
functions). Diagram
1.5.3 Data Abstraction
Data abstraction is an encapsulation of an object’s state and behaviour. Data abstraction increases the power
of programming language by creating user defined data types (Fig. 1.4). Data abstraction also represents the
needed information in the program without presenting the details.

Fig. 1.4 Data Abstraction

1.5.4 Data Encapsulation


Data encapsulation combines data and functions into a single unit called
class. When using data encapsulation, data is not accessed directly; it is
only accessible through the methods (functions) present inside the class.
Data encapsulation enables data hiding, which is an important concept
possible of OOP (Fig. 1.5). Fig. 1.5 Data Encapsulation
Introduction to Object Oriented Programming 5

1.5.5 Information Hiding


Information hiding means that the implementation details of an object’s state and behaviour are hidden from
users and other objects to protect the state and behaviour from unauthorised access (Fig. 1.6).

Fig. 1.6 Information Hiding

1.5.6 Message Passing


In OOPs, processing is accomplished by sending messages to objects (Fig. 1.7). How messages are
executed or implemented is defined in the class methods. Methods give the implementation details for the
messages and represent a class behaviour. A message passing is equivalent to a procedure call or a function
call of a procedural programming.

Fig. 1.7 Message Passing within Objects

1.5.7 Inheritance
Inheritance is the process of forming a new class from an existing class or base class. The base class is also
known as parent class or super class. The new class that is formed is called derived class. Derived class is
also known as a ‘child class’ or ‘sub-class’.
Sub-classes (derived classes) inherit some or all of the
properties of their superclasses (base classes). Inheritance
organises classes into a hierarchy, allowing implementation
and structure to be shared. Thus, reuse becomes automatic
as the code from a superclass can be reused by a subclass.
New classes inherit both the state and behaviour from Fig. 1.8 Single Inheritance
existing classes.
In single inheritance, each subclass has only one immediate superclass (Fig. 1.8).
In multiple inheritance, each subclass has more than one superclass (Fig. 1.9).
6 Programming with C++

Inheritance helps to reduce the overall code size of


the program, which is an important advantage of object-
oriented programming.

1.5.8 Dynamic Binding


In dynamic binding, message passing to the objects
can be done during run time. Late binding or run time
binding have the same meaning as dynamic binding.
In a procedural programming, procedure call or
function invocation can be done only during compilation
and it is called as static binding or early binding of Fig. 1.9 Multiple Inheritance
a compiler. In a pure object oriented programming,
message passing to the objects can be done only during run time.

1.5.9 Polymorphism
Polymorphism uses dynamic binding and virtual methods by which different descendant objects can
respond in their own unique ways to the same method. Polymorphism enables programmers to manipulate
subclass objects using superclass references.

1.5.10 Overloading
Overloading allows an object to have different meanings depending on its context. There are two types
of overloading, namely, operator overloading and function overloading. When an exiting operator begins
to operate on a new data type, it is called operator overloading. When a message passing to the objects is
done with a different data type, or class, then it is called as function overloading. Overloading is one type
of polymorphism.

1.6 ADVANTAGES OF OOPs

The major advantages, benefits and merits of OOPs are given below:
1. Since OOP provides a better syntax structure, modelling real world problems is easy and flexible.
2. Complex software systems can be modularised on the basis of objects and classes.
3. Creation and maintenance of an OOP code is easy and hence reduces software development time.
4. Since OOP technique supports reusable software components libraries, software reengineering
can be synthesised, implemented and realised easily. For example, reusable software components
libraries are called as standard templates in C++ and packages in Java.
5. The abstract data type concept decouples the object specification and object implementation.
6. Data encapsulation and information hiding increases software reliability and modifiability.
7. Polymorphism and dynamic binding increases flexibility of code by allowing the creation of generic
software components.
8. Inheritance allows software code to be extensible and reusable. New attributes and new operations
can be added through the creation of new child object classes without modifying the original code.
Introduction to Object Oriented Programming 7

1.7 DISADVANTAGES OF OOPs

The main drawbacks of using OOPs in modern software development life cycles (SDLC) are:
1. OOP software development, debugging and testing tools are not standardised.
2. The functional data and process decomposition tools such as Entity-Relationship (ER) diagrams and
Data Flow Diagrams (DFD) modules need to be adapted to allow for OOP decomposition of classes
and objects.
3. Even though OOP reduces the software development time, OOP has a steep learning curve. Software
engineers, system analysts and programmers need to learn to model real world problems into a set of
interacting objects and class hierarchies.
4. OOP decomposition of a large hierarchy of classes is complex and difficult to manipulate especially
for computer novices.
5. In real life software applications, hierarchy of classes must be decomposed properly using OOP
based tools as inheritance and polymorphism can hide from a bad design.
6. Polymorphism and dynamic binding also require long processing time, due to overhead of function
calls during the run time.

1.8 COMPARISON OF STRUCTURED PROCEDURAL PROGRAMMING SPP


AND OBJECT ORIENTED PROGRAMMING OOP
In order to understand the basic concepts in C++, a programmer must have a command of the basic
terminology in object-oriented programming. Table 1.1 summarises the major characteristics and salient
features of SPP and OOP:

Table 1.1 Major characteristics and salient features of SPP and OOP
Characteristics SPP OOP
1. Program modularisation On the basis of functions On the basis of data structures called objects and
classes
2. Design approach Top-down Bottom-up
3. Data Move openly around the system Data is mostly hidden or permits restricted access
from function to function. due to public, private and protected rights.
By default, all data are public and By default, all data are private and hence provide
hence provide global access. local access only.
4. Problem emphasis Represented by logical entities and Represented more closely with interacting
control flow objects and classes.
5. Usage of abstraction Procedural abstraction Class and object abstraction
6. Function call (method Programmers are responsible for Active objects communicate with each other by
invocation) calling the active procedures to pass passing messages to activate their operations
parameters and arguments
7. Unit/module structure Statement or expression Object treated as a software component

(Contd)
8 Programming with C++

(Contd Table 1.1)

Characteristics SPP OOP


8. Code reusage It does not support code reusability Due to class hierarchy a part of the state and
behaviour can be re-engineered to a subclass
9. Problem decomposition Functional approach Object oriented approach
10. Function and procedure Mostly shares global data State (data types) and behaviour (methods) are
tied together in a data structure called an object
11. Code Binding By default, all function calls are It supports both early (static) binding and late
static or during compilation time. (dynamic) binding.
There is no provision for late Method invocation can be done even during run
binding. time.
12. Polymorphism It does not support. No concept of Polymorphism and dynamic binding are the
virtual functions. major features of OOP
13. Languages Procedure oriented languages, such Object Oriented Languages, such as C++, Java,
as C, Pascal, Modula-2, FORTRAN C#, Smalltalk, Simula, CLOS

1.9 STEPS IN DEVELOPING OOP PROGRAMS

There is a fundamental shift in the way programs are designed, developed, tested, and maintained using
OOP methodology. Programmers should realise that in the OOP approach, object oriented decomposition is
mostly emphasised in place of functional decomposition. Secondly, grouping of object classes on the basis
of hierarchical dependency of classes is maintained instead of grouping functions together.
Following are the steps to develop a new software system using the object oriented approach:
1. State the problem, that is, the user requirements are analysed and given in a simple descriptive
language.
2. Identify the object classes and their attributes (data members) and the data operations (member
functions) associated with each object class as a guideline.
3. The system specification is broken into a number of modules, with each module consisting of one or
more object classes.
4. Declare and define each object class by encapsulating its attributes and operations.
5. Identify the message passing between interacting object classes by identifying requests answered and
services required by each object class.
6. Identify inheritance relations and class hierarchies on the basis of dependencies between object
classes.
7. Create a logical OOP model for the proposed system that shows the interaction between objects.
8. Develop algorithms for member functions of each object class to process its data members.
9. Plan an implementation strategy to code OOP program modules using an appropriate OOP language.
10. Prepare, test, deliver, and maintain plans for the new software.
Introduction to Object Oriented Programming 9

1.10 STRUCTURE OF OBJECT ORIENTED PROGRAMS

In C++, classes are first declared and are normally put in a separate header file. Then the member functions
for each class are defined. Finally, the user code is written to create instances of classes (objects) and
to perform the required tasks. A class’s attributes and behaviours are implemented using data members
(instance variables) and member functions, respectively.
Information hiding is implemented by declaring members (data or functions) with one of the three
categories of accessibility: private, public, and protected. Any function (member or nonmember) can
access a public member. Only member functions of the class can access a private member. When members
are protected, they can be accessed by member functions of the base class and its derived classes but not by
nonmember functions. A derived class inherits all members from the base class.
The member functions can be divided into two categories:
1. Constructor, which creates and initializes an object, and destructor, which destroys the object. They
carry the same name as the class and are called automatically.
2. Implementor functions, which perform the required operations of the object.

PROGRAM 1.1

A program to illustrate how to construct a single linked list using object oriented programming technique.
// Implementation of Single Linked List
// List demonstration
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
struct node_info {
int data;
struct node_info *ptr;
};
class single_list {
private:
struct node_info *head;
struct node_info *list;
public:
void list_initialize();
void create_list();
void traverse_list();
void menu();
};
void single_list :: list_initialize()
{
head = list = NULL;
}
void single_list :: menu()
{
cout << “Implementation of Single Linked list \n”;
cout << “ a -> adding an element to the list \n”;
cout << “ t -> traversing the list \n”;
cout << “ m -> help menu \n”;
cout << “ q -> quit from the main program \n”;
}
10 Programming with C++

void single_list :: create_list()


{
struct node_info *temp;
temp = (struct node_info *) malloc(sizeof(struct node_info));
cout <<“ Enter data to the current Node\n”;
cin >> temp->data;
if (head == NULL) {
head = temp;
temp->ptr = NULL;
list = temp;
}
else {
list->ptr = temp;
temp->ptr = NULL;
list = temp;
}
}
void single_list :: traverse_list()
{
struct node_info *temp;
if ( head == NULL ){
cout << “The list is empty \n”;
return;
}
else {
temp = head;
while ( temp != NULL ) {
cout <<“ Content of the Node =”;
cout << temp->data << “\n”;
temp = temp->ptr;
}
} //end of else statement
}
int main()
{
single_list obj;
char ch;
obj.list_initialize();
obj.menu();
cout << “enter your choice \n”;
while (( ch = getchar()) != ‘q’) {
switch (ch) {
case ‘a’:
obj.create_list();
break;
case ‘t’:
obj.traverse_list();
break;
case ‘m’:
obj.menu();
break;
case ‘q’:
exit(1);
} // end of switch statement
} // end of while statement
return 0;
}

Output of the above program

Implementation of Single Linked list


a -> adding an element to the list
t -> traversing the list
m -> help menu
Introduction to Object Oriented Programming 11

q -> quit from the main program


Enter your choice
a
Enter data to the current Node
10
a
Enter data to the current Node
20
a
Enter data to the current Node
30
a
Enter data to the current Node
40
t
Content of the Node =10
Content of the Node =20
Content of the Node =30
Content of the Node =40

1.11 OBJECT ORIENTED LANGUAGES

It is well known that Object Oriented Programming provides major advantages in the creation and
maintenance of software. These include shorter development time and a high degree of code sharing and
flexibility. These advantages make object oriented programming an important technology for building
complex software systems now and in the future. A number of languages are claimed to be object oriented.
The following are certain well-known Object Oriented Programming languages:
∑ smalltalk
∑ Common Lisp Object System (CLOS)
∑ Object Pascal
∑ Object C
∑ C++
∑ Java
∑ C#

1.12 IMPORTANCE OF C++


C++ is a general-purpose, platform-neutral compiled programming language that supports various
programming paradigms, including procedural programming, object-based programming, object-oriented
programming, generic programming and functional programming.
In recent times, the object oriented programming (OOP) paradigm has become popular in modern
software life cycles. Now, C++ has the status of a structured programming language with Object Oriented
Programming (OOP) methodology, in which the software reusability, testability, maintainability, portability
and reliability are the key features and requisities of modern software development.
Despite a serious competition with Java, Visual Basic, and Microsoft .NET family of languages (e.g.
C#), C++ is the only truly object oriented language adopted by the IT industry. The most significant impact
of C++ is its ability to support many different programming paradigms. C++ easily adapts to procedural
abstraction, modular abstraction, data abstraction and most importantly object oriented programming.
The important features added in C++ are a class construct with private, public and protected sections.
The derived classes provide both single and multiple inheritance mechanism. The additional facilities
included are as follows:
12 Programming with C++

∑ polymorphism
∑ dynamic binding
∑ virtual functions
∑ run time type checking
∑ overloading functions and operators
∑ exception handling
∑ standard template libraries
C++ has become quite popular due to the following reasons:
∑ It supports all features of both structured programming and object oriented programming.
∑ It gives the easiest way to handle data hiding and encapsulation with the help of powerful keywords
such as class, private, public and protected.
∑ Inheritance, one of the most powerful design concept is supported with single inheritance and
multiple inheritance of base class and derived classes.
∑ Polymorphism through virtual functions, virtual base classes and virtual destructors give the late
binding of the compiler.
∑ It provides overloading of operators and functions.
∑ C++ focuses on function and class templates for handling parameterized data types.
∑ Exception handling is done by the extra keywords, namely, try, catch and throw.
∑ C++ provides special member functions such as friends, static methods, constructors and destructors
for the class objects in order to create and destroy the objects easily and effectively.
∑ Standard Template Library (STL) supports not only containers, iterators and algorithms to perform
operations such as searching and sorting but also templates for generic algorithms.

REVIEW QUESTIONS
1. What is meant by object-oriented paradigm?
2. Explain the importance of OOP technology.
3. Define the following terms with respect to OOP:
(a) objects (b) classes (c) data abstraction
(d) data encapsulation (e) information hiding (f) message passing
(g) inheritance (h) dynamic binding (i) polymorphism
(j) overloading
4. What are the demerits of using a structured procedural programming?
5. Explain how an OOP technique improves the software system.
6. Summarise the advantages and disadvantages of OOP.
7. Compare the Structured Procedural Programming (SPP) with that of an Object Oriented
Programming (OOP).
8. Explain the steps involved in developing OOP.
9. Summarise the major Object Oriented Languages used in the field of software engineering.
10. Elucidate the importance of C++.
Chapter
Building ANSI
C++ Programs 2
This chapter presents the history of C++ language and also highlights some
of the key terms that are used extensively in ANSI/ISO C++. This chapter also
shows the ways and means of how to write, compile, debug and execute a C++
program under different environments, namely, GNU C++ under Linux/UNIX
OS and Visual C++ under .NET Windows platform.

2.1 INTRODUCTION

This section is for those people who want to learn programming in C++ and do not necessarily have any
previous knowledge of other programming languages. Of course, any knowledge of other programming
languages or any general computer skill can be useful to better understand this tutorial, although it is not
essential.

2.2 HISTORY OF C++


The evolution of C++ has been a continuous and progressive process, rather than a series of brusque
revolutions. C++ today is very different from what it was in 1983, when it was first named “C++”. Many
features have been added to the language since then; older features have been modified, and a few features
have been deprecated or removed entirely from the language. Some of the extensions have radically
changed the programming styles and concepts.
The list of extensions include: const member functions, exception handling, templates, new cast
operators, namespaces, the Standard Template Library, bool type, and many more. These have made C++
the powerful and robust multipurpose programming language that it is today.
14 Programming with C++

2.2.1 Origins of C++


Simula67 was the first object oriented programming language which was introduced in late 1960s. It was
mainly used for writing event-driven simulations. Classes, inheritance and virtual member functions were
integral features of the Simula67.
Smalltalk first appeared way back in 1972 which offered not only a pure object-oriented programming
environment but also added many features from Simula67, Ada and Modula-2. In fact, Smalltalk and
Simula67 were not only the precursors to object oriented programming but also made considerable
contributions to development of OOP.

2.2.2 C with Classes


The style of C programming was so innovative and revolutionary that it became a standard in the software
industry for designing Operating Systems (OS) under UNIX. C is not only a general purpose programming
language but also widely accepted 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.
In 1979, Bjarne Stroustrup of AT&T started to experiment with extensions to C to make it a better tool
for implementing large-scale projects. By adding classes to C, the resultant language ‘C with classes’ could
offer better support for encapsulation and information hiding. The core of the C language was retained in
“C with classes” and that added most of the OOP features from Smalltalk and Simula67.

2.2.3 Enter C++


Several modifications and extensions were made to ‘C with classes’ in 1983 in order to meet the requirement
for the software industry and consequently the language ‘C with classes’ was renamed as “C++”.
Between 1985 and 1989, C++ underwent a major reform. Protected members, protected inheritance,
templates, and multiple inheritance were added to the language. A number of compilers and extensions to the
language were introduced by many software vendors. It was clear that C++ needed to become standardised.

2.2.4 ANSI Committee Established


In 1989, American National Standards Institution (ANSI) constituted a committee for standardising C++.
The official name of the committee was X3J16, and later it was changed to J16.
The ANSI C committee used ‘The C Programming Language’ by Kernighan and Ritchie as a starting
point. Likewise, the ANSI C++ committee used the ‘Annotated C++ Reference Manual’ by Ellis and
Stroustrup as its base document for building and standardising.

2.2.5 The Importance of Standardising C++


The following points highlight the importance of standardising C++:
It is no doubt that C++ is probably the most widely used programming language both
1. Language Stability
in commercial and in academic establishments today. Learning it from scratch is a demanding and time
consuming process. It is guaranteed that, henceforth, learning C++ is a one-time investment rather than an
iterative process.
2. Code Stability Due to different versions of C++ compilers from various software vendors, code stability
and uniformity becomes an important problem faced by the developers. Therefore, ANSI standard specifies
a set of deprecated features that might become obsolete in the future. Other than that, fully ANSI-compliant
code is guaranteed to work in the future.
Building ANSI C++ Programs 15

3. Manpower Portability Since the language commonality is enforced, C++ programmers can switch more
easily to different environments, projects, compilers, and to different software companies.
4. Easier Portability The standard defines a common denominator for all platforms and compiler vendors,
enabling easier porting of software across various operating systems and hardware architectures.

2.3 THE LATEST ADDENDA TO ANSI/ISO C++

This section summarises a panorama of the latest addenda to the ANSI/ISO C++ Standard. This section also
explains some of the key terms that are used in the standard:
1. New Typecast Operators The new cast operators make the programmer’s intention clearer and self-
documenting. The following keywords are used to handle the typecast operation in ANSI C++:
∑ static_cast
∑ dynamic_cast
∑ const_cast
∑ reinterpret_cast
2. Run Time Type Identification The Run Time Type Identification (RTTI) of an object can be accomplished
by the following keywords:
∑ typeid
∑ type_info
3. Built-in Bool TypeThe built-in bool data type was added to the ANSI C++ standard. The use of explicit
keywords such as ‘true’, ‘false’, and ‘bool’ is self-documenting and is more evident than the use of int values.
Hence, readability and portability are the major advantages of using a standardised Boolean data type.
4. Namespaces Namespaces were the latest feature to be added to the language. Namespaces are used
to prevent name conflicts and to facilitate configuration management and version control in large-scale
projects. Most of the components of the Standard Library are grouped under namespace std.
5. Exception Handling Exception handling is used to report and handle runtime errors and that has been refined
and improved in ANSI C++. The following keywords are used to handle the error handling mechanism:
∑ try
∑ catch
∑ throw
6. Constructing Safer Classes and Objects ANSI/ISO C++ supports the safe form of constructing classes and
objects from unintentional modification of data member or its member functions. The following keywords
are used for declaring objects as a mutable object member, const data or const member function, etc.
∑ const
∑ explicit
∑ mutable
7. Templates The old pattern of using macros was replaced with the templates. A template is a mold or a
blueprint from which related functions or classes are instantiated. The new template features give advantage
of writing compact codes for functions and classes.
8. The Standard Template Library (STL) The Standard Template Library, or STL, comprises a substantial part
of ANSI/ISO C++ addition. STL is a collection of generic containers, iterators, function objects, allocators
16 Programming with C++

and algorithms. Some of the examples for generic containers are vector, list, and stack. Generic algorithms
are used for sorting, finding, merging, and transforming these containers.
9. New Form of Standard I/O Streams The standard stream and string classes have been templatized to
support both narrow and wide characters. The keyword wchar_t is used to handle wide character streams.
10. New Form of Using Header File The use of header file has been modified in ANSI C++ standard. The new
standardised class libraries such as complex, string, exception, etc., are also added.
11. Memory Management The Standard now defines deploying the auto_ptr for the safe release of
dynamically created objects. Overloading of the operators new and delete and advanced memory
management techniques are the additional features in the ANSI C++.
12. Constructors and Destructors Fundamental data types can be initialised by a special constructor. In
addition, the standard also defines a pseudo destructor for each of these types.

2.4 POSSIBLE FUTURE ADDITIONS TO C++

It is speculated that the following new features will be added to C++ in future:
∑ Automatic garbage collection
∑ Object persistence
∑ Support for concurrency and multithreading
∑ Extensible member functions
∑ Dynamically linked libraries
∑ Rule-based programming
However, automatic garbage collection, concurrency, and object persistence are already implemented in
many other object oriented programming languages. In future, they may be added to C++ as well.

2.5 C++ VERSUS C

C++ is not only derived from the C language, but also a superset of C that means almost every correct
statement in C is also correct in C++. The most important elements added to C are concerned with classes,
objects and object oriented programming.
The following features of the C++ language or library are not supported in C. A major portion of C++
and its library fall into this category. A partial list of these features includes:
∑ anonymous unions
∑ classes
∑ constructors and destructors
∑ exceptions and try/catch blocks
∑ external function linkages
∑ function overloading
∑ member functions
∑ namespaces
∑ new and delete operators
∑ operator overloading
∑ reference types
∑ standard template library (STL)
Building ANSI C++ Programs 17

∑ template classes
∑ template functions

2.6 VERSIONS OF C++


Many software vendors have released ANSI C++ specific compilers for different platforms. Following is a
partial list of well-known C++ compilers that are used globally. Some of the compilers can be downloaded
for free from the internet and the others have to be acquired by making the specified price.
∑ Apple C++
∑ Borland C++
∑ GNU C++ for Linux
∑ IBM C++ for IBM power, System Z
∑ HP C++ for Unix and HP C++ for OpenVMS
∑ Intel C++ for Windows and Linux
∑ SGI C++
∑ Sun C++
∑ Microsoft Visual C++ under .Net
∑ Turbo C++
Compatibility Notes The ANSI C++ standard which is accepted as an international standard is of recent
origin. It was released in November 1997, even though C++ language exists from 1980. Therefore, there
are many compilers which do not support all the new capabilities included in ANSI C++, specially those
released prior to the publication of the standard.

2.7 SOURCE PROGRAM NAMES


C++ is a hybrid language, supporting both the structured programming language “C” and Object Oriented
Programming“C++”. Therefore, a C++ compiler can accommodate both C and C++ languages. So, it is
essential to have a method to determine the type of code that is processed. To perform a C compilation, the
source program files have an extension of .C. On the other hand, files have an extension of .CPP for specific
C++ compilation.
Unlike several other programming languages, C++ does not impose a specific programming paradigm
on its users. This liberty has two major advantages: it enables reuse of C code with minimal or no
modifications at all, and it enables designers to choose the paradigm that suits their needs best.

2.8 COMPILING AND DEBUGGING C++ PROGRAMS

This section introduces key mechanics of C++ such as warnings, errors, portable code generation and
performance optimisation. Compiling is the process of translating a source code into an executable code.
Debugging is the art of making that code error free and make it run. These are the mechanical aspects of
programming. Programmers need to know how to run compilers and debuggers which are the essential tools
for a good programmer.

2.8.1 The Compilation Process (Fig. 2.1)


Compilation involves the following four separate processes which always take place in the following order:
18 Programming with C++

(a) Preprocessor
The preprocessor expands directives such as #include in a
program. This output is piped directly to the compiler.
(b) Compiler
The compiler translates the preprocessed C and C++
statements into the assembly language and stores it in an
intermediate file.
(c) The assembler
The assembler translates the assembly language statements
into object code and stores it in an intermediate file ending
in “.obj”.
(d) The Linker
The linker combines the program’s object code files with
any required libraries to create the finished executable
code. This output is stored as a.out in case of Linux/UNIX Fig. 2.1 The Compilation Process
C++ compiler and “. EXE” for the Visual C++ compiler or
Borland Turbo C++ compiler.
2.8.2 Types of Program Errors
The following section deals with the different types of errors and warning messages during the compilation
and execution of a program. Errors are caused by syntactical mistakes in source code such as typographical
errors, missing semicolons and other kinds of faulty constructions. In general, programming errors can be
classified into two types, namely, compile time errors and runtime errors.
(a) Compile Time Errors The compile time errors are caused due to the improper use of C++ syntax and
semantics of the language. All syntax errors and some of the semantic errors (the static semantic errors) are
detected by the compiler during the compilation stage. The C++ compiler generates a message indicating
the type of error and the position in the C++ source file where the error has occurred. It is to be noted that
the actual error could have occurred before the position signalled by the compiler.
(b) Run Time Errors Run time errors are another class of errors which are not identified during compilation
time. These errors are caused by dynamic semantic errors and logical errors in a program that cannot be
detected by the compiler during the debugging stage. The program is compiled and executed but does not
generate the required result.
It is the responsibility of the programmer to find and fix the run time errors if any, in a program to get the
desired output. There is a difference between a warning and an error. A warning is a message the compiler
prints when it discovers a potential problem in the source code. An error is a mistake in the syntax that
prevents the compiler from finishing its job.
(c) Warnings Warnings are frequently caused by missing declarations, values of inappropriate types and
various kinds of improper constructions. Despite the warning, the program’s source code is syntactically
correct, so these types of problems do not prevent the compiler from creating a finished code file. However,
that code might not run correctly. Warnings are sometimes called compile-time errors.

2.9 STAGES OF PROGRAM DEVELOPMENT FIG. 2.2


A little knowledge is necessary before one can write and compile programs on any computer system. Every
programmer goes through the following three-step cycle during a program development:
Building ANSI C++ Programs 19

Fig. 2.2 Stages of Program Development

1. Writing the program into a file


2. Compiling the program
3. Running the program
During program development, the programmer may repeat this cycle many times, refining, testing and
debugging a program until a satisfactory result is achieved.
20 Programming with C++

2.10 COMPILING GNU GCC/G++ IN LINUX

Gcc stands for gnu compiler collection. Gnu is a type of licence for free, open source software. Majority
of gnu softwares are for unix-based systems. A compiler is a system software used to convert source code
into a file that the computer can execute. So gcc refers to a collection of Unix-based, free softwares which
convert source code into machine code.

(1) Editing the Source Program


Writing, editing and entering a program into a computer system and storing it as a source file is called the
preparation of the program text. Linux supports vi (Visual Editor) for editing a C++ program. The type
of file assumed when specifying a C++ source files depends on its extension, which must be one of the
following lists:
.C
.cc
.cxx
.cpp and
.c++
For example,
$ vi rst.cpp

(2) Compiling the Source Program


The GNU gcc/g++ compiler can perform preprocessing, compilation, assembly and linking of a project
from a single call to gcc/g++. Its format is:
$ gcc rst.c (for C program)
or
$ g++ rst.cpp (for C++ specific compilation)
At this point if there are errors in the source program, the compiler will show them on the screen. One
should correct these errors by opening the program in the text editor, namely, vi editor.
After the errors have been corrected, one may use the same gcc or g++ command to compile it again. If
there are no errors in the source code, the compiler will return the prompt without any error messages. This
means that the source code has been compiled into a separate executable file which by default is named as
a.out.

(3) Running the Compiled Program


To run the code by typing in a.out at the prompt as follows:
$ ./a.out
The most common way of calling g++ to compile a single source file in C++ is:
$ g++ source le -o exec le
where source file is the C++ source file to compile and execfile is the name of the output file, generally the
executable file, which must always be preceded by the -o option.
For example,
$ g++ rst.cpp -o rst
Instead of a.out, g++ creates an executable named “first” and one can execute the file in the following
way:
Building ANSI C++ Programs 21

$./ rst
To know more about the GNU g++ compiler options, one can use the Linux g++ manual. The command
is as follows:
$ man g++

2.11 COMPILING C/C++ PROGRAM IN UNIX

Just as C++ is a superset of C, the C++ compilers are very similar to C compilers in that their options are
usually a superset of C compiler options. The basic compiling information about C is also applicable to
C++, with the following exceptions:
CC (upper case), g++ and gcc are all C++ compiler commands on the UNIX systems that provide C++.
Source filename extension conventions are compiler-dependent. Extensions include:
.C (upper case)
.c (lower case)
.cxx
.cpp
.cc
.c++

(a) Writing the Program The easiest way to enter a source program is using a text editor like vi, emacs or
xedit. To edit a file called rst.c using vi as
$ vi rst.cpp

(b) Compiling the Program The C++ compiler is invoked with CC (upper-case), g++ or gcc. There are
additional compiler options specific to C++.
For C program compilation, one of the following compiler commands is used:
$ cc rst.c
or
$ gcc rst.c
For C++ specific compilation, one of the following compiler commands is invoked:
$ CC rst.cpp
or
$ g++ rst.cpp

(c) Running the Program To run a program under UNIX, the following command is used:
$./a.out
In Unix systems, any file can be labelled as an executable, and it is common to either use the .o
extension, or to have no extension at all.
$ g++ helloworld.cpp -o helloworld
Now, instead of a.out, g++ creates an executable named “helloworld”
$./helloworld
To know more about the cc/CC/gcc/g++ compiler options, one can use the UNIX manual. The
command is as follows:
$ man CC
22 Programming with C++

2.12 BUILDING C++ UNDER MICROSOFT .NET PLATFORM

This section explains how to edit, compile and build a C++ program under Visual Studio .NET Framework
which is one of the most widely used platforms for learning and developing ANSI C++ programs.

(1) Visual Studio .NET Framework (Fig. 2.3) Visual Studio supports the Microsoft .NET Framework, which
provides the Common Language Runtime (CLR) and unified programming classes. Visual Studio .NET is the
tool for rapidly building high performance desktop applications and Web and ASP applications. It supports
the following programming languages:
∑ Visual C++
∑ Visual Basic
∑ Visual C#
∑ Visual J#

Fig. 2.3 Visual Studio .NET Framework

The .NET Framework is a multi-language environment for building, deploying, and running XML Web
services and applications. It consists of three main parts:
∑ Common Language Runtime
∑ Unified programming classes
∑ ASP.NET
Building ANSI C++ Programs 23

The framework provides developers with a unified, object-oriented, hierarchical, and extensible set of
class libraries (APIs).

(2) Microsoft Visual C++ .NET (Fig. 2.4) It is well known that Microsoft Visual C++ .NET 2003 provides
the dynamic development environment for creating Microsoft Windows-based and Microsoft NET-based ap-
plications, dynamic Web applications, and XML Web services using the C++ development language. Visual
C++ .NET includes the industry-standard Active Template Library (ATL) and Microsoft Foundation Class
(MFC) libraries, advanced language extensions, and powerful integrated development environment (IDE)
features that enable developers to edit and debug source code efficiently.
It provides developers with a proven, object-oriented language for building powerful and performance-
conscious applications. With advanced template features, low-level platform access, and an optimizing
compiler, Visual C++ .NET delivers superior functionality for generating robust applications and
components. The product enables developers to build a wide variety of solutions, including Web
applications, smart-client Microsoft Windows-based applications, and solutions for thin-client and smart-
client mobile devices. C++ is the world’s most popular system-level language, and Visual C++ .NET 2003
gives developers a world-class tool with which to build software.
The following steps are used to create, edit and build a C++ program under Microsoft Visual .NET studio.
To select the Visual Studio .NET from the Start Menu, Click Start Menu and select All Programs ->
Microsoft Visual Studio .NET 2003 –> Press Microsoft Visual Studio .NET 2003.

Fig. 2.4 Microsoft Visual C++ .NET

(3) Start Page (Fig. 2.5) The Start Page has been re-designed for this release. One can still set the user pref-
erences for IDE behaviour and access new or existing projects, but with a user interface designed to be easier
to navigate. Both the My Profile and Project sections now have their own tabs. The Online Resources tab now
contains useful Microsoft related online developer resources.
24 Programming with C++

Fig. 2.5 Microsoft Development Environment Design — Start Page

(4) Integrated Development Environment (IDE) In the Menu bar, select File Æ New Æ Project
Visual C++ Projects
An application wizard provides a user interface that is used to create a project, modelled after a project
template, and generate source files and directories for applications.
The wizard provides program structure, basic menus, toolbars, icons, and appropriate #include
statements. Visual C++ application wizards work in conjunction with application frameworks and libraries
to create starter programs for the user.

Fig. 2.6 Creating a Project with a Visual C++ Application Wizard


Building ANSI C++ Programs 25

(5) Creating and Managing Projects (Fig. 2.6) Every type of Visual C++ project has an application wizard
that helps the user generate new projects quickly and easily, modelled from the project template.

(a) Project types Visual Studio contains a project template or application wizard for the following project
types. Each wizard helps to create projects:
∑ ASP.NET Web Service Template
∑ Class Library Template
∑ Console Application Template
∑ Empty Project Template
∑ Windows Control Library Template
∑ Windows Forms Application Template
∑ Windows Service Template
To open an application wizard, the New Project dialog box has to be used to specify the project
properties like the name, or the directory and solution where your project will reside.
To open a Visual C++ application wizard
1. On the File menu, click New, and then click Project. The New Project dialog box appears.
2. In the Project Types pane, select the Visual C++ Projects folder. An icon for every type of C++
project appears in the Templates pane.
3. In the Templates pane, select an icon to choose a project type. A message appears under both panes
indicating the type of project the user is going to create.
4. Specify your project properties, or skip this step to use Visual Studio default project properties.
5. Click OK, and the wizard for your project type opens.

Fig. 2.7 Creating a Project with a Console Application Template


(b) Console application template (Fig. 2.7) The Console Application project template adds the necessary items
needed to create a console application. Console applications are typically designed without a graphical user
interface and are compiled into a stand-alone executable file. A console application is run from the command line
with input and output information being exchanged between the command prompt and the running application.
26 Programming with C++

As information can be written to and read from the console window, this makes the console application a great
way to learn new programming techniques without having to be concerned with the user interface.
The template automatically adds the essential project references and files to use as a starting point for
your application. Header files “Stdafx.h” — Used to build a precompiled header file named Win32.pch and
a precompiled types file named StdAfx.obj

(6) Adding and Removing Solution


Items (Fig. 2.8)
(a) Solution Explorer To efficiently man-
age the items that are required for devel-
opment such as references, data connec-
tions, folders, and files, Visual Studio
.NET provides two containers: solutions
and projects. An interface for viewing
and managing these containers and their
associated items, Solution Explorer, is
provided as part of the integrated devel-
opment environment (IDE).
Solution Explorer provides the user
with an organised view of his projects
and their files as well as ready access
to the commands that pertain to them.
A toolbar associated with this window
offers commonly used commands
for the item you highlight in the list. Fig. 2.8 Selecting the Solution Explorer on the View Menu
To access Solution Explorer, select
Solution Explorer on the View menu.
(b) Removing Solution Items (Fig 2.9) One can remove an item
from the Solution Items folder. Removing is not the same as
permanently deleting an item. Removing takes away the item’s
association with the solution. The file that represents the former
item still remains on disk.
To remove a solution item
1. In Solution Explorer, select the item the user wants to
remove.
2. On the Edit menu, choose Remove.
3. One can re-add the item as long as the file for the item
still exists.
(c) Adding Solution Items To add a new solution item
1. In Solution Explorer, select the Solution node.
2. On the Project menu, choose Add New Item.
3. From Add New Solution Item, choose a template.
4. Choose Open to add the item to the Solution Items folder.
To add an existing item to a solution
1. In Solution Explorer, select the solution.
Fig. 2.9 Removing Solution Items
Building ANSI C++ Programs 27

2. On the Project menu, choose Add Existing Item.


3. From Add New Solution Item, choose the item the user wants to add.
4. Choose Open to add the item to the Solution Items folder.

(7) Adding New Project Items (Fig.


2.10(a) & (b)) Adding a project item
is one way to extend the functionality
of an application. Examples of project
items include HTML pages, Class files,
Web Services, ASP pages, Dataset files,
and Style sheets. The types of files that
the user can add to a project are deter-
mined by the project template used to
create it.
To add a new project item
1. In Solution Explorer, select a
target project.
2. On the Project menu, select Add
New Item.
3. Select a Category in the left
pane.
4. Select an item Template in the
right pane. Fig. 2.10(a) Adding New Project Item
5. Select Open.

Fig. 2.10(b) Adding New Project Item


28 Programming with C++

(8) Editing and Saving C++ Programs (Fig. 2.11a)


(a) Editing Start entering a C++ program on the editor pane.
For example,
#include “stdafx.h”
#include <iostream>
using namespace std;
int main()
{
cout << “this is a test program by Ravich \n”;
return 0;
}
(b) Saving (Fig. 2.11b) Save a file, On the
File menu, click Save First.cpp
Save a copy of a file
1. On the File menu, click Save As.
2. In the File name box, enter a new
name for the file.
3. Click Save.

(9) Preparing and Managing Builds (Fig.


2.12) Visual Studio .NET offers a variety of
ways to help the user to organise files which
are required for a solution or a project.
To build or rebuild a single project
1. In Solution Explorer, select or open
the desired project.
2. On the Build menu, choose Build
[Project Name] or Rebuild [Project Fig. 2.11(a) Editing a C++ Program on the Editor Pane
Name].
Note: “Cleaning” a solution or project
deletes any intermediate and output
files, leaving only the project and
component files, from which new
instances of the intermediate and
output files can then be built.
To build or rebuild an entire solution,
on the Menu bar, select Build –> Build
Solution.
On the Build menu, choose Build
Solution or Rebuild Solution. Choose
Build or Build Solution to compile only
those project files and components that
have changed since the last build. Choose
Rebuild Solution to “clean” the solution
first, and then build all project files and
components. Fig. 2.11(b) Saving a C++ Program
Another random document with
no related content on Scribd:
The Project Gutenberg eBook of Le signe sur
les mains
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

Title: Le signe sur les mains


roman

Author: Emile Baumann

Release date: January 19, 2024 [eBook #72759]

Language: French

Original publication: Paris: Bernard Grasset, 1926

Credits: Laurent Vogel (This file was produced from images


generously made available by the Bibliothèque
nationale de France (BnF/Gallica))

*** START OF THE PROJECT GUTENBERG EBOOK LE SIGNE SUR


LES MAINS ***
ÉMILE BAUMANN

LE SIGNE
SUR LES MAINS
ROMAN

PARIS
BERNARD GRASSET
61, RUE DES SAINTS-PÈRES

1926
DU MÊME AUTEUR

Les grandes formes de la Musique (Albin Michel, éditeur).


L’immolé, roman (Bernard Grasset, éditeur).
La Fosse aux Lions, roman (Bernard Grasset, éditeur).
Trois Villes saintes (Bernard Grasset, éditeur).
Le Baptême de Pauline Ardel, roman (Bernard Grasset, éditeur).
L’Abbé Chevoleau, caporal au 90e d’infanterie (Perrin, éditeur).
La Paix du septième jour (Perrin, éditeur).
Le fer sur l’Enclume (Perrin, éditeur).
Job le Prédestiné, roman (Bernard Grasset, éditeur).
L’Anneau d’or des Grands Mystiques (Bernard Grasset, éditeur).
Saint Paul (Bernard Grasset, éditeur).

Édition de luxe :

Heures d’été au Mont Saint-Michel, avec des gravures sur bois de


René Pottier.
IL A ÉTÉ TIRÉ DE CET OUVRAGE : TREIZE EXEMPLAIRES
SUR PAPIER JAPON, DONT DIX NUMÉROTÉS JAPON 1 à
10 ET TROIS, JAPON H. C. I à H. C. III ; TRENTE-SIX
EXEMPLAIRES SUR PAPIER HOLLANDE, DONT TRENTE
NUMÉROTÉS HOLLANDE 1 à 30 ET SIX, HOLLANDE H.
C. I à H. C. VI ; ET CENT TRENTE-CINQ EXEMPLAIRES
SUR PAPIER VÉLIN PUR FIL LAFUMA, DONT CENT
VINGT-CINQ NUMÉROTÉS VÉLIN PUR FIL 1 à 125 ET
DIX, VÉLIN PUR FIL H. C. I à H. C. X.

Tous droits de traduction, de reproduction et d’adaptation réservés


pour tous pays.
Copyright by Bernard Grasset 1926.
A
Mademoiselle GENEVIÈVE DUHAMELET
après avoir relu ses Poèmes ; Agnès les eût aimés.

AUX JEUNES AMIS


CONNUS ET INCONNUS
qui retrouveront en Jérôme quelque chose d’eux-mêmes.
I

Au moment où Jérôme entra, rue de Vaugirard, dans la chapelle


des Carmes, l’office du Samedi Saint était commencé. Comme tous
les ans, la veille de Pâques, on y faisait l’ordination des clercs.
Devant le tabernacle se tenait agenouillé, en chape violette, avec ses
assistants, un majestueux évêque dont un acolyte portait la crosse.
Les surplis des prêtres emplissaient le chœur ; des têtes chauves
brillaient sous le soleil qui pénétrait, à droite, par le vitrail du
transept.
Les yeux de Jérôme ne se tendirent qu’une minute vers l’autel.
Au milieu de la nef, la double rangée des ordinands formait en demi-
cercle une couronne d’aubes et de cierges, le long d’un tapis où,
solennellement, s’avancèrent ceux qui allaient être ordonnés, les uns
sous-diacres, les autres diacres, quelques-uns, prêtres. Ils se mirent
à genoux, puis, les mains croisées sous leur front, ils s’allongèrent,
demeurèrent immobiles. Le clergé avait entonné les litanies des
Saints ; l’Église triomphante s’entendait appeler à soutenir de sa
puissance l’infirmité des médiateurs terrestres. Eux, avant de se lier
par les rites irrévocables, ils signifiaient leur volonté de mourir à tout
ce qui n’était pas Dieu ; ils restaient couchés là, pareils à des
cadavres, comme de grands lys foudroyés.
Jérôme, leste et mince, pour mieux voir, s’insinua entre les
chaises pressées des fidèles, jusqu’au centre de la nef. Il considéra
ces corps de jeunes hommes, prostrés en ligne, sur deux rangs. Les
diacres, par-dessus leur aube, étaient ceints d’une étole, comme des
soldats d’un baudrier. La couleur rouge étalée dans l’or du tapis lui
représenta des flaques sinueuses de sang, le sang frais de
combattants abattus, la face dans la poussière, parmi des blés qui
mûrissent. Il songea :
— Si Montcalm était ici…
Montcalm, son aîné de deux ans, un camarade tué à la guerre,
cinq mois avant la fin ; une de ces amitiés que le silence de la mort
approfondit !
« Qu’est-ce qu’un mort ? a dit quelqu’un. Un absent qui n’écrit
plus. »
Montcalm avait-il besoin d’écrire ? Quand était-il absent ? Depuis
l’heure où il partit en patrouille et ne reparut jamais, Jérôme gardait
comme gravé au couteau dans sa mémoire son regard d’adieu ;
même le son de ses dernières paroles vibrait en lui.
A Moulin-sous-Touvent, le soir du 3 juin, au crépuscule, ils
marchaient l’un derrière l’autre, le long d’un boyau fangeux.
Montcalm s’avançait le premier, penchant la tête, massif et grave. Un
brusque pressentiment le saisit ; il s’arrêta, se retourna, dit à
Jérôme :
— Tu sais où je dois aller après cette guerre, si j’en reviens
(Jérôme savait qu’il se destinait, tardivement, au séminaire). Si je
meurs, tu prendras ma place. Est-ce promis ?
— Alors, tu n’en veux pas revenir ?
— Est-ce promis ? insista Montcalm qui posa une main sur son
épaule et le regarda comme s’il lui passait le fardeau d’une mission
sacrée. Il tendait vers son ami son visage honnête et rubicond, sa
forte mâchoire de rural vendéen. Un sourire mystique commentait
son adjuration. Jérôme ne se raidit point sous l’imprévu de cette
violence :
— Si Dieu l’exige, répondit-il, si, moi-même, j’en reviens, vieux,
c’est promis.
Ils s’étreignirent sans rien ajouter. Montcalm, dans la nuit
tombante, reprenant sa marche, semblait en route déjà pour les
pays d’outre-tombe…
Deux semaines plus tard, Jérôme eut le bras droit cassé par une
balle. La fracture était sérieuse ; la maladresse d’un major en
compromit la guérison. Une faiblesse lui resta dans les muscles qui
le rendit pour longtemps inapte à tenir un fusil. L’armistice le libéra ;
il rentra chez sa mère, alors installée aux environs de Saint-Cloud,
sur la hauteur de Garches.
Il ne lui parla point de la promesse faite à Montcalm.
La mort de Montcalm était-elle bien sûre ? Suffisait-elle à certifier
l’appel divin ?
Ai-je la vocation ? s’interrogeait-il. Et il interrogea Dom Estienne,
son confesseur, un vieux bénédictin prudent. Celui-ci conseilla
simplement : « Attendez et priez. »
Jérôme attendait plus qu’il ne priait. La grandeur du sacerdoce,
parfois, l’attirait, même l’enivrait. Mais, avec la fougue de ses vingt
et un ans, il s’élançait aux joies palpables, comme un affamé ouvre
ses narines à l’odeur d’un pain chaud. Il préparait un examen tout
profane : l’École d’agriculture de Beauvais, où il se proposait d’être
admis, l’armerait de méthodes neuves pour l’exploitation de ses
terres, en Vendée. L’histoire étant une de ses passions, il suivait
aussi des cours à l’Institut catholique. C’est pourquoi il avait dirigé
ses pas vers la chapelle des Carmes ; au spectacle de l’ordination il
voulait s’éprouver, s’imaginer lui-même en soutane et en aube, pareil
à quelqu’un de ces prostrés sur qui le chœur chantait les litanies des
Saints.
Elles retentissaient, plus triomphales que funèbres, au-dessus
des victimes dont allait se consommer l’oblation. Les fortes voix du
clergé, celles, plus flottantes, de la foule, déroulaient
impersonnellement la continuité naïve des versets et des réponses.
L’Église dénombrait les colonnes de l’invisible basilique édifiée et
enrichie par les siècles. Elle conviait à défiler autour des ordinands, à
leur tendre la main, l’armée des anges et des archanges, tous les
Ordres des Esprits bienheureux, les Patriarches et les Prophètes, les
Apôtres et les Évangélistes, les Martyrs, les Confesseurs, les Vierges,
les Veuves, les Ermites, les Pénitents ; et le Christ lui-même, avec
son étendard, semblait descendre, comme dans les limbes, au-
devant de ces ensevelis pour les initier a sa gloire.
Mais le cri suppliant de la misère se prolongeait : Délivre-nous,
Seigneur ! Entends-nous, nous t’en prions. Te rogamus, audi nos…
Jérôme s’unissait aux réponses ; leur gaillardise populaire
allégeait de sa tristesse la longue prostration. Il se disait en même
temps :
« A quoi pensent-ils, ces hommes qui vont faire le pas, ou qui,
tout à l’heure, seront des prêtres ? Est-ce au monde dont ils se
séparent, aux tendresses désirables qu’ils n’auront pas connues ? A
l’immensité des dons, des pouvoirs, aux terribles charges qu’ils
assument ? Est-ce à leur indignité ? Ou cèdent-ils à la douceur du
suprême abandon ? Ils savent que c’est bien fini, qu’ils sont la part
du Seigneur ; ils se remettent en leur néant pour renaître dans
l’Esprit Saint. Ils porteront, quand même, jusqu’au bout, leur chair
de péché, la loi de la sottise et de l’orgueil. Montcalm, lui, dans cette
posture, n’aurait eu qu’une idée : « Le Maître m’a voulu ; j’obéis ; je
servirai dans l’amour. » Il était prêtre avant de l’être. Ceux qui sont là
ressemblent-ils à Montcalm ?
Moi, je suis loin de leur obéissance. Je n’ai, comme dirait Dom
Estienne, ni l’attrait surnaturel, ni l’intention droite. Je ne mérite pas
le choix d’en Haut. J’ai le goût de rester libre. Oh ! la soutane, un
suaire noir. Moi, Jérôme Cormier, en soutane !… Non, ça ne m’irait
point. Et pourtant…
Il s’arrêtait au bord de cet aveu :
« Tu es faible devant toi-même ; tu as peur du sacrifice. La
vocation vient-elle de toi ? Si tu l’as, qui l’aura faite ? »
Les ordinands s’étaient relevés ; le demi-cercle des aubes et des
cierges se reforma. Jérôme admirait les visages purs et tranquilles
des clercs debout en face de lui. Son enthousiasme les jugeait
« sublimes, angéliques ». Et, en effet, un rayon intérieur dégageait
des plus ternes quelque chose de doux dans la force, d’intrépide
dans la modestie.
La Messe commença. Entre le Kyrie et l’Évangile les ordinations
se succédèrent. Chaque fois qu’un nom, en latin, était appelé, le
candidat répondait : Adsum, Me voici, le mot d’Abraham quand le
Seigneur lui mit en main le couteau pour l’immolation d’Isaac.
Ce mot, la plupart des ordinands le proféraient d’une voix rapide,
effacée, un peu comme le soldat répond : Présent à l’appel du
quartier. Mais il enfermait toutes les acceptations jusqu’au martyre ;
dans la chapelle des Carmes, le martyre pouvait-il ne point être
évoqué ?
Ce fut entre ses murs, qu’en 1792, les septembriseurs
entassèrent et jugèrent, avant la tuerie méthodique, les prêtres
qu’ils n’avaient pas massacrés dans le jardin. Sur le marbre de la
table où l’on communie, les bourreaux venaient aiguiser leurs
sabres. Puis, les condamnés étaient poussés, par la galerie, vers le
palier du jardin. A mesure qu’ils se montraient, on les précipitait sur
les piques, on les sabrait, on les fusillait.
Jérôme avait maintes fois passé devant le petit perron, au bas de
la muraille enfumée, sous les fenêtres grillées comme celles des
cachots. Contre la rampe de fer, entre le double escalier, il avait vu la
simple inscription : Hic ceciderunt, ils sont tombés ici. Il avait assisté
à une Messe dans la crypte où les parois de marbre noir cachent les
ossements des cent quarante prêtres martyrisés. Il avait retenu de
ces contacts une dure leçon d’ascétisme, un vague effroi qui
s’étendait au séminaire tout entier. Une partie de lui-même s’exaltait
à de tels souvenirs héroïques ; l’humain de ses appétits les répudiait.
Cependant il suivait avec attention les rites. Le Pontife, assis ou
debout, déposant ou reprenant sa mitre, lisait d’une voix claire les
augustes oraisons. Les ordinands montaient s’agenouiller, se
relevaient : tonsurés, portiers, lecteurs, exorcistes, acolytes, sous-
diacres portant pliée sur le bras gauche la dalmatique, « vêtement
de joie », et qui touchaient le calice, la patène vides, en témoignage
du don d’eux-mêmes sans retour.
« Voulez-vous boire mon calice ? » leur disait intérieurement le
Prêtre éternel. Ils répondaient : Oui. Jérôme entendait une voix
insidieuse lui souffler : « Le calice est trop amer. Qu’il passe loin de
toi. »
Sur la tête des nouveaux diacres, le Pontife étendait la main
droite ; il mettait à leur cou l’étole blanche, symbole de candeur, de
bienheureuse immortalité et leur faisait toucher le livre des
Évangiles.
Mais à l’ordination des prêtres était réservée la plus ample
liturgie. Jérôme observa la petite nappe qu’ils tenaient pour lier et
laver leurs mains.
Le consécrateur lut l’admonition latine où l’on rappelle
qu’autrefois le peuple était consulté.
« C’est avec une grande crainte, poursuivait-il, qu’on doit monter
à une dignité si haute… Il faut qu’une sagesse céleste, des mœurs
probes, une longue pratique de la justice recommandent les élus…,
qu’ils soient les vieillards du peuple. »
Il associait à l’Église future, incarnée dans les nouveaux prêtres,
toute celle des temps passés, depuis les Apôtres, depuis Moïse et les
soixante-dix hommes choisis dans Israël…
Puis il se leva, et, sans discours ni chant ni aucune parole, il
imposa les deux mains à chacun des diacres agenouillés. Les prêtres
qui l’entouraient passèrent devant eux, faisant de même. Enfin, tous
ensemble, le Pontife et les prêtres étendirent leur main droite sur les
têtes inclinées.
Dans le silence des assistants graves et saisis Jérôme perçut le
lourd sanglot d’une mère défaillant sous l’holocauste de son fils. Il se
représenta sa mère à lui, s’il était parmi les élus.
« Elle aurait le courage de ne point pleurer ; mais, avant, quel
drame ! »
Le Pontife, sur la poitrine des ordinands, avait disposé, en forme
de croix, l’étole qui figure le joug du Seigneur, suave et léger. Il avait
abaissé le long de leur corps la chasuble, emblème de la charité
parfaite.
Alors il s’agenouilla, entonna le Veni creator, et le chœur, à
pleines voix, scanda l’hymne brûlante, l’hymne implorante. Jérôme
croyait communier sans réserve à l’élan de l’invocation. Avec le
clergé, avec ses frères chrétiens, avec l’Église de l’univers, il adjurait
l’éternel Visiteur, « source vive, feu, onction spirituelle », le Souffle
Saint dont le toucher fait les cœurs aimants et pacifiques.
Mais, cette paix divine, lui-même en possédait-il la constance ?
Pendant qu’il chantait le Veni creator, des images profanes
s’insinuaient autour de sa pensée, l’enlaçaient délicatement pour
l’attirer au loin.
— Agnès et Antoinette auraient dû venir ; elles seraient émues…
Antoinette et Agnès Duprat étaient les deux sœurs. Leur mère,
veuve d’un magistrat nantais, venait de mourir d’une lente maladie
de cœur, aux Clouzeaux, bourg vendéen, où sa maison avoisinait la
Brunière, le domaine de Mme Cormier. Celle-ci, qui l’aimait, et plus
encore aimait ses filles, les avait recueillies, pour quelques mois, à
Garches. Jérôme s’était fait d’elles, malgré leur tristesse, deux amies
délicieuses. Presque à son insu elles captivaient sa vie d’un naïf
enchantement. Chacune l’occupait par une amitié différente :
fraternelle avec l’aînée, Antoinette, jeune personne vive et
raisonnable, qui se proposait, quand elle aurait marié sa sœur, de
prendre, au couvent de la rue du Bac, l’habit des Filles de la Charité ;
plus inquiète, plus tendre aussi avec la singulière Agnès. Pour lui
plaire, Agnès avait mieux que la fraîcheur de ses dix-huit ans : une
intelligence aiguë, des saillies originales, des alternances de rêverie
et d’enthousiasme ; il surprenait chez elle, sous des élans mystiques,
une aspiration réprimée à tous les bonheurs pressentis, mais un je
ne sais quoi de violent, de faible, de douloureux qui le troublait.
Au milieu d’une cérémonie dont tous les rites prêchaient le
renoncement, le souvenir d’Agnès s’interposa comme pour protester
contre d’austères desseins. L’idée de sa présence lui survint telle
qu’au premier instant où, après des années, ils s’étaient revus.
Il rentrait, vers midi, par le sentier qui passe au bas du jardin ; en
ouvrant la porte, il avait levé les yeux ; dans l’embrasure d’une
fenêtre elle se tenait debout, regardant, comme éblouie, la plaine où
tremblait, sous la brume, Paris lointain, semblable à une ville
ensevelie qu’on découvrirait au fond d’une mer transparente. Son
grand deuil faisait valoir ses bras nus, nerveux, rosés en plein soleil,
avec des fossettes d’ombre dans leurs plis.
Au bruit de son pas, elle se pencha, puis se retira vivement ;
mais, l’ayant reconnu, elle se montra de nouveau ; comme il la
saluait d’un air joyeux, elle s’inclina en souriant…
La présence imaginaire s’est écartée, ce qu’on fait dans la
chapelle ressaisit Jérôme. Le Pontife assis ôte ses gants ; devant lui,
les ordinands fléchissent les genoux ; et, chacun ayant ses mains
jointes, il les oint de l’huile des catéchumènes, du chrême qui servait
jadis à sacrer les rois. Avec son pouce il étend l’huile en deux lignes
formant une croix ; il trace sur ces mains humides un lent signe de
croix,
« afin que tout ce qu’elles béniront soit béni, que tout ce qu’elles
consacreront soit consacré et sanctifié. »
Un des assistants prend la nappe que l’ordinand présente entre
ses doigts ; il en lie la main droite sur la gauche ; aux deux mains
ainsi liées le Pontife tend le calice où l’on a mêlé le vin et l’eau ; il
leur donne le contact de la patène qui porte l’hostie ; et il prononce
les paroles de transmission :
« Recevez le pouvoir d’offrir le sacrifice à Dieu, de célébrer la
Messe aussi bien pour les vivants que pour les morts. »
Quand les prêtres ordonnés sont redescendus de l’autel, Jérôme
contemple leurs mains ; il ne s’arrête pas à examiner si elles sont
blanches ou rougeaudes, fines ou épaisses, grossières ou
patriciennes. Il les sait consacrées ; elles béniront, elles baptiseront ;
déployées au-dessus de l’hostie et du calice elles aideront la Parole
au miracle du pain et du vin transsubstantiés ; elles seules
toucheront le Corps du Seigneur. Ces mains, saintes à présent,
même si elles devenaient impures, tiendront les clefs invisibles ; sans
leur geste rien de ce qui est lié ou délié dans le ciel ne saurait, sur la
terre, se délier ou se lier.
Jérôme les voit marquées d’un signe mystérieux impossible à
détruire. L’huile de l’onction a beau être essuyée ; les deux lignes en
forme de croix demeurent incrustées du pouce à l’index, jusqu’au
dedans des paumes, à jamais.
La puissance inamovible de ce caractère émerveille Jérôme ; et
cependant un effroi le traverse à la simple idée qu’il devrait un jour
en recevoir le signe. Il se retranche dans son indignité, il ne veut pas
que ses mains à lui soient enchaînées ni ointes.
« Etre libre », c’est le cri de sa jeunesse impatiente. Le poulain se
méfie de la bride et du mors ; il ne comprend que l’appel des
herbages ou le clairon du vent qui a bondi sur les vagues. Jérôme
est tourmenté d’un sourd malaise ; il s’ennuie au voisinage de ces
esclaves du Christ qui, tout à l’heure, vont, une fois de plus,
s’agenouiller devant l’évêque et promettre obéissance. Il prend son
chapeau, comme pour s’en aller. Mais il se ravise en pensant :
— Montcalm serait là ; je resterais ; et que dirait le Père ?
Celui qu’on appelle, chez Mme Cormier, « le Père », est l’oncle
paternel de Jérôme, un ancien missionnaire que ses infirmités ont
réduit à l’inaction ; sa belle-sœur lui donne asile, et ce vieux malade
exerce dans la maison une suprématie ; Jérôme lui-même éprouve
son ascendant ; la présence du « Père » domine, qu’il le veuille ou
non, tous ses actes.
Il reste donc jusqu’au bout de la Messe magnifique concélébrée à
voix haute par le Pontife et les nouveaux prêtres. Le tumulte de son
indépendance s’est calmé. Il s’associe à la majesté du Sacrifice, à
l’attente pascale, dans la douceur de la divine Communion.
Cependant, lorsqu’il sort de la chapelle, il part aussi allègre qu’un
écolier s’échappant à la fin d’une classe trop longue. D’un pas
impétueux il descend la rue d’Assas ; il va comme pressé par un
rendez-vous d’amour. Il éparpille sa force dans les choses
extérieures ; il est content de faire sonner sous ses talons le trottoir
ensoleillé. Du bonheur passe pour lui, même dans les nuages
dispersés au delà des toits fumants. La terre lui semble belle comme
un navire pavoisé voguant vers des îles bleues, au matin d’un
printemps qui se voudrait éternel.
II

Dans la salle à manger aux boiseries très blanches Mme Élise


Cormier présidait la table, ayant un prêtre à sa droite, et, à sa
gauche, un autre prêtre, l’oncle Gaston, « le Père ». Vis-à-vis d’elle,
entre les deux jeunes filles, la place de Jérôme était vide. On ne
l’avait pas attendu parce que l’invité, le chanoine Langevin, devait
repartir avant trois heures.
Le sérieux des soutanes, la robe noire d’Antoinette et d’Agnès, le
dossier haut des chaises de cuir brun, le rectangle étroit, allongé de
la table, le crucifix dressé contre le mur, derrière la maîtresse de
maison, imposaient à cet intérieur une sévérité conventuelle. Il y
avait pourtant sur la nappe une corbeille en argent, ornée de
violettes et de primevères. Les vastes fenêtres accueillaient la
fraîcheur mouvante, verte et fauve, des premières feuilles du jardin.
Autour des cheveux d’Agnès, d’Antoinette et de leurs joues délicates
tremblait un duvet de clarté. Blonde, rose, Mme Élise effaçait mal,
sous le gris monastique de son corsage, les grâces d’une maturité
plantureuse ; elle conservait, à quarante-deux ans, un éclat de
jeunesse presque ingénu, un air de sérénité virginale. Le profil
arrondi, vermeil du chanoine Langevin, avec sa bouche finement
narquoise, rappelait ces abbés du XVIIIe siècle, trop bien portants,
trop heureux, qui, du haut de leurs portraits, font honte à l’anémie
d’arrière-neveux moroses. Chaque fois qu’il venait à Paris, Mme
Cormier le recevait comme un ami d’enfance de son mari défunt. Il
était arrivé de Luçon la veille, chargé, auprès du Cardinal, d’une
mission confidentielle qu’il voulait remplir le jour même.
A ces visages affables « le Père » opposait la rudesse tourmentée
du sien : une tête carrée, des tempes puissantes ; des cheveux drus,
presque blancs, des sourcils irréguliers qu’il fronçait comme s’ils
allaient lancer des foudres, une mâchoire tendue, une barbe divisée
en deux pointes qu’étirait sa main noueuse ; une mine de
commandement ; l’œil de feu d’un faucon dévorant les espaces. Sa
figure aurait pu être celle d’un vieux Chouan terrible ; le pli
sacerdotal, la maladie, la prière, une volonté de renoncement
l’avaient adoucie, épurée. Son teint jaune déclarait le mauvais état
de son foie. Il mangeait peu ; une tasse de lait avec du pain grillé
suffisait à sa réfection. Mais, quand il parlait, c’était, selon son
habitude, en prophète, comme ayant seul le droit d’être écouté :
— Vous croyez, braves gens, la guerre finie ? Détrompez-vous ; la
paix n’est qu’une fausse trêve ; les fléaux sont en marche. Ces
quatre années sanglantes n’auront été qu’une piqûre de guêpe
auprès de ce qui nous attend…
Mme Élise, quoique résignée, de longue date, à ses vaticinations,
les sentait irritantes pour l’optimiste chanoine ; elle tourna vivement
vers son beau-frère ses yeux mutins, et, sur un ton de gentillesse
suppliante :
— Oh ! Père, je vous en prie, épargnez-nous, laissez-nous, entre
deux crises, au moins respirer…
— Cher ami, dit le chanoine, s’évertuant à rester bénin, vous
ressemblez toujours au sombre Ézéchiel, lorsqu’il trouvait doux
comme miel le livre amer qu’il avait mangé, plein de lamentations et
de menaces affreuses. Serons-nous tentés au delà de nos forces ?
Les Victimes n’intercéderont-elles plus ?
Le Père allait justifier ses prophéties, indigné qu’elles fussent
mises en doute. Mais on venait d’entendre la grille de la villa se
refermer brusquement. Un pas agile bondit sur le perron. Mme Élise
eut à peine le temps d’annoncer :
— Voici Jérôme !
Il entra, rouge, un peu haletant d’être monté si vite. Son arrivée
fut la diversion joyeuse. Il baisa le front de sa mère, serra la main de
son oncle et du chanoine ; les deux jeunes filles lui tendirent le bout
de leurs doigts. Désirée, la cuisinière, présenta sur la table une
dorade friande que Mme Élise découpa ; et, tandis que Jérôme
expliquait son retard, le Père lui demanda comment s’était passée
l’ordination :
— Les ordinands, je le suppose, ne brillaient guère par le
nombre…
— Oui, répondit Jérôme, ils sont trop peu. C’était beau, quand
même. J’ai vu de près l’onction des mains ; je n’en avais aucune
idée.
— Autrefois, observa son oncle, si un prêtre était noté d’infamie,
il subissait le rite opposé. L’évêque, pour le dépouiller du pouvoir de
consacrer et de bénir, lui raclait les mains avec un couteau ou un
morceau de verre.
Antoinette soupira :
— Elles devaient être en sang !
— Rassurez-vous, Mademoiselle, intervint l’érudit chanoine.
L’Église ne fut jamais inhumaine. Le Pontifical recommandait à
l’évêque de les racler doucement, légèrement, sine effusione
sanguinis.
Agnès examinait les mains du chanoine et celles du Père. Elle
murmura cette remarque étrange :
— Les prêtres portent donc un signe sur les mains ?
— Je le croirais, dit Jérôme, et même je me demande si, dans
certains cas, le signe ne devient point un héritage de famille.
Mme Élise se prit à rire, le chanoine hocha la tête, et le Père
fronça les sourcils comme en face d’un paradoxe inquiétant. Jérôme
poursuivit :
— Je vous étonne ; mais je pense à mon ami Montcalm. Un soir,
nous étions tous les deux, seuls dans notre cagna ; il se mit à
genoux, pria longuement ; ensuite il me confia que, s’il rentrait
vivant au pays, il serait prêtre ; et il me révéla le motif, un des motifs
de sa vocation. Montcalm ne s’appelait pas Montcalm ; son vrai nom
était Brindeau ; allié par sa mère aux Sainte-Flaive, une ancienne
famille du Bocage qui possédait quelques terres près de chez nous.
Son grand-père, me dit-il, avait changé de nom pour cacher une
honte. Pendant la Terreur, le baron de Sainte-Flaive émigra ; sa
femme et sa fille, n’ayant pu le suivre, furent jetées en prison, à
Nantes. Elles plurent au geôlier ; il leur offrit de s’enfuir avec elles,
de s’embarquer pour l’Espagne. Il ne posa qu’une condition : la
jeune fille l’épouserait. Mme de Sainte-Flaive consentit ; ce geôlier
était un bel homme ; il sut abuser la demoiselle, après avoir ébloui la
mère. Le ménage eut trois fils ; plus tard, on sut que l’ex-geôlier,
c’était un ci-devant prêtre. Eh bien ! Montcalm pensait qu’il devait
réparer le sacrilège de l’aïeul. Et il concluait : « J’ai dans les veines
du sang d’un prêtre ; quelque chose de plus fort que moi me porte
au sacerdoce. » Il a réparé avec son propre sang…
Jérôme s’étonna d’avoir ainsi parlé ; en dévoilant, à cette heure,
le secret de Montcalm, il semblait se mettre sur le chemin d’avouer
la suprême injonction du mort, celle dont il demeurait chargé. De
celle-là, il croyait bien que jamais l’aveu n’échapperait à ses lèvres.
Un silence succéda où il put écouter l’écho de son récit prolongé
jusqu’au fond des cœurs, comme la chute d’une pierre rebondissant
le long des parois d’un puits. Mais le chanoine, théologien
scrupuleux, éprouva le besoin de commenter :
— La vocation, chez votre ami, et l’onction des mains reçue par le
ci-devant prêtre, ces deux faits n’ont entre eux aucun lien formel.
— Qu’en savez-vous ? contredit le Père, enclin à scruter les
choses qui se perdent dans l’insondable.
La brusque révélation de Jérôme sur Montcalm avait choqué Mme
Élise. Pourquoi son fils ne lui avait-il rien dit, à elle d’abord, de cette
bizarre confidence ?
Elle poussa l’entretien vers un sujet où le Père et le chanoine
n’auraient pas, croyait-elle, occasion de se heurter. L’abbé Langevin,
quelques mois auparavant, avait fait un séjour à Rome ; elle se disait
curieuse de le suivre aux catacombes. Il raconta que, dans celles de
Saint-Calixte, le Trappiste qui le guidait l’avait arrêté devant un petit
bas-relief en marbre figurant des Amours ailés montés, comme des
coureurs, sur des chevaux lancés à toute bride : « Quoi de chrétien
dans ce motif ? » avait-il interrogé. Et le Trappiste avait répondu :
« Païen, mais beau. »
— En France, continua l’abbé, on n’imagine guère un Trappiste ni
même personne d’entre nous osant pareille phrase. Au fond de nos
mœurs et de nos préjugés survit un jansénisme incurable.
— Le jansénisme avait du bon, protesta le Père avec une moue
agressive. C’était un bastion contre la veulerie des mœurs. J’aime
mieux ça que nos dévotions de camelote, l’illusion du salut au rabais,
du salut qui ne coûte rien.
Le chanoine, d’un ton poli, se rebiffa :
— Alors, comment expliquez-vous, mon Père, que partout où
s’implantèrent des évêques et un clergé jansénistes, la foi ait décliné
plus promptement qu’ailleurs ?
Par-dessus la tête de Mme Élise une controverse, entre les deux
ecclésiastiques, s’aiguisa, un croisement de fer que la modération du
chanoine maintint courtois. Antoinette, silencieuse, effacée,
observait le choc de leurs arguments ; Agnès et Jérôme s’isolaient
dans une causerie à mi-voix :
— Païen, mais beau ! reprenait Jérôme. J’aime cette largeur de
vues. Après tout, la nature est l’œuvre de Dieu, et la chair n’est
point maudite, ni l’amour de la beauté, un crime.
— Je pense comme vous, dit Agnès ; ou plutôt je pense très peu.
Pour moi, les êtres existent, les idées, à peine. Tout à l’heure,
questionnez encore le chanoine sur l’Italie. Je voudrais tant
connaître Rome, et, je ne sais pourquoi, la Sicile. Je rêve de Malte,
de l’Afrique. Je me figure, dans les pays du Sud, la vie plus divine et
simple. Vivre, oh ! vivre !…
— Je crois vous comprendre, dit Jérôme, ému de sa confiance,
surpris de ces velléités nostalgiques. Mais enfin, vivre, qu’est-ce
donc pour vous ?
Les paupières aux cils bruns d’Agnès eurent un léger battement ;
une rougeur vague anima ses joues, et sa tête se détourna comme
dans une fuite charmante. Après une pause brève elle répondit
pourtant :
— Je n’en sais rien au juste ; je désire parce que j’ignore…
Elle faillit lui retourner sa question : « Et vous, sous le mot vivre,
que mettez-vous ? » Elle n’osa, pas plus qu’il n’osa la presser
davantage.
Mais, en ces minutes d’intimité, pour la première fois il reçut le
contact réel de sa présence. Apercevoir qu’elle avait un teint
diaphane, des yeux pers que la courbure des cils rendait caressants,
des lèvres minces un peu renflées aux commissures, un profil dont le
nez pointu relevait les contours alanguis, une main svelte, une voix
hésitante et veloutée qui semblait sortir d’un rêve nonchalant, ce
n’était pas la connaître. Mais elle venait d’entr’ouvrir son âme ;
Jérôme fut avide soudain de la pénétrer.
Il ne se croyait point amoureux d’Agnès ; il ne pensait trouver en
elle qu’une agréable amie. Cependant saurait-il s’arrêter à une
sympathie éphémère ? S’il n’avait rien démêlé, chez la sœur
d’Antoinette, de plus profond, il se fût tenu en garde contre de vains
élans. La noblesse et le péril, pour lui, d’une telle amitié, c’en était
l’ingénuité catholique. Un cœur formé à l’absolu de l’amour le
transporte dans les sentiments profanes. Il ne pouvait aimer à demi,
ne livrer qu’une parcelle de lui-même. Agnès lui témoignait une sorte
de furtif abandon ; son premier mouvement fut un trouble
voluptueux. Mme Élise la définissait « une dormeuse qui attend
l’heure de s’éveiller. » Jérôme pouvait se croire la cause ou l’occasion
de l’éveil. Et l’appel d’Agnès répondait, en lui, au frémissement d’une
jeunesse jusqu’alors contenue par de chastes disciplines. Car il avait
traversé les hasards de la guerre et les promiscuités de l’arrière-front
sans être une seule fois victime des occasions charnelles. Montcalm,
là encore, l’avait protégé, Montcalm qui, à la veille d’une offensive,
lui déclarait : « Si je meurs, tu sais, je meurs vierge. »
Dans la naïve sentimentalité d’Agnès il trouvait néanmoins une
part de factice, de suranné. Il refusait d’en être dupe. Volontiers, il
l’aurait avertie : « Vivre, ce n’est pas exiger le bonheur pour soi ;
vivre, c’est se donner… » Mais il avait horreur de paraître pédant, de
faire le moraliste. Et de quel droit la prêcher ? N’inclinait-il pas,
autant qu’elle, à ménager entre Dieu et le monde un compromis où
la part cédée à Dieu restait infime ?
Ces idées graves n’effleurèrent qu’un instant son attention,
comme se mêle à l’air d’une rue l’odeur d’encens d’une église, quand
on ouvre les portes et qu’on les referme aussitôt. Sa conscience se
dissipa dans les menus faits du dehors.
Le déjeuner fini, comme le chanoine disposait encore d’un
moment, Mme Élise lui proposa de visiter le jardin ; elle aurait plaisir
à lui en faire les honneurs. Elle gardait la passion de planter,
d’aménager ; le seul luxe où elle se divertissait était celui des fleurs,
des arbres, de la basse-cour.
La maison qu’elle avait achetée, pendant la guerre, voulant
suivre Jérôme jusqu’au terme de ses études, se dressait au bord
d’un promontoire, à l’endroit que jadis occupa le château des princes
de Beauveau-Craon, bombardé, ruiné, en 1871, par les obus
allemands.
Le jardin, au-dessous, dévalait sur la pente, et s’appuyait à la
lisière des bois qui, jusqu’à la crête de Buzenval, couvrent la courbe
aimable du coteau. Quelques têtes d’arbres se hérissaient encore
nues ; mais le vert sortait partout, frais, le long des branches noires,
comme une pluie lustrale. Les cerisiers, les poiriers d’un blanc
cotonneux, les lilas, les pêchers tremblants sous leur floraison
frileuse avaient l’air de reposoirs fragiles disposés pour une grande
fête.
— L’enchantement du Samedi Saint, dit Antoinette à Jérôme.
Il fermait la marche ; le chanoine précédait, accompagné
d’Antoinette et d’Agnès. Mme Élise allait en avant, légère et pimpante
avec son chapeau de paille aux rubans mauves. Quant au Père, il
s’était retiré dans sa chambre, mécontent du chanoine, parce qu’il
n’avait su, au terme de leur discussion, le contraindre à rendre les
armes ; il conservait, d’ailleurs, des pays chauds, l’habitude d’une
sieste après midi où il réparait, assez mal, des nuits sans sommeil.
Mme Élise s’égayait à célébrer au bon abbé Langevin les
promesses de ses poiriers :
— Voici mes William, mes Doyenné du Comice, mes Tour Eiffel…
— Des Tour Eiffel ! s’exclama le jovial chanoine. Il faudra, pour les
avaler, le secret du trou de l’aiguille par où passe un chameau.
— Eh bien ! dit-elle, à l’automne, je vous en ferai goûter. Vous
verrez, Monsieur le Chanoine, qu’elles passeront très bien.
Elle l’emmena vers le jardin français dessiné d’après ses plans.
Les ronds des pelouses, les rectangles, les lignes triangulaires se
combinaient en rythmes séduisants. Sur les longues bandes de
gazon, des ifs coniques, sans paraître s’ennuyer trop, se faisaient
vis-à-vis. Une vasque d’un galbe pur régnait au centre d’un parterre
qu’entouraient des rosiers. Les plus précoces des roses étaient à
peine en boutons. Avec discernement le chanoine salua certaines
étiquettes :
— Oh ! La rose soleil ! Le bouquet de la mariée !
Il suivit Mme Élise à droite, parmi les choux du potager, auprès de
la basse-cour. Les poules étaient logées par espèces, entre de clairs
treillages ; un sable fin garnissait leur parc. Dans une cabane proche
on entendit la voix amicale d’une chèvre ; deux chevreaux
s’élancèrent en galopant comme des fous. Ils se poursuivaient l’un
l’autre, sautaient sur un banc de bois, en redescendaient. Leur mère
les rejoignit, une chèvre syrienne, grise, au poil soyeux, qui vint
contre la grille coller son museau gourmand. Tandis que Mme Élise et
Antoinette lui présentaient des bouts de pain, les petits grimpaient
sur son dos, s’insinuaient entre ses jambes, la queue frétillante, pour
tirer ses pis énormes ; puis ils repartaient, cabriolant, et, tout d’un
coup, s’arrêtaient, ahuris, mutins, capricieux, ivres de bon lait, ivres
d’être au monde.
Mme Élise s’amusait, Antoinette et le chanoine aussi, de leurs
gambades ingénues. Les âmes simples retrouvent auprès des
animaux innocents quelque chose qui remémore la joie du premier
Paradis.
Mais Jérôme et Agnès les avaient devancés auprès du « chenil ».
Mme Élise dénommait ainsi, en badinant, l’enclos où vivaient séparés,
d’un côté, un ménage de petits dogues, de l’autre, un jeune chien-
loup, à poil fauve moucheté de noir, nerveux de membrure, avec les
oreilles en cornet, des yeux cerclés de jaune, la mine agressive et
fougueuse. Celui-ci allait et venait, derrière les grillages, le cou
tendu, à pas allongés, comme un léopard dans sa cage.
— Mob ! appela Jérôme.
Le chien s’étira, bâilla, vint flairer les mains de son maître. Mais,
voyant approcher la soutane du chanoine qu’il ne connaissait pas, il
se ramassa brusquement, prêt à bondir, et poussa des aboiements
furieux. Les dogues, à plein gosier, firent chorus.
— Ce molosse, plaisanta le bon abbé, promet d’être anticlérical.
— N’y voyez pas d’intention personnelle, répliqua Mme Élise. Mais,
comme disait Désirée, il n’est pas commode, le bestiau.
— Je me demande, réfléchit tout haut Jérôme, pourquoi la
brutalité de ce chien m’attire. J’aime jusqu’à ses fureurs et à son
envie de mordre. Au fond, je ne crois qu’à la force.
Le chanoine, qui exigeait des idées nettes, rectifia d’une voix
paisible :
— Vous le dites, mon cher ami ; le pensez-vous ? La force n’est
point la brutalité. Les Livres Saints ont raison : « La sagesse vaut
mieux que la force. »
Antoinette, en riant, vint à la rescousse, appuya :
— Et vous m’oubliez ! La charité ? qu’en faites-vous ?
— La charité ! s’écria Jérôme, mais c’est la suprême force. J’adore
le Christ parce qu’il a vaincu la mort, parce qu’il reviendra en
triomphateur à la fin des temps…
Il jeta sa réplique avec une pointe de jactance juvénile. Agnès le
regarda ; elle crut voir autour de son visage cette clarté glorieuse qui
ceint le front des héros ; et vivement elle abaissa ses paupières, de
peur qu’on ne s’aperçût qu’elle l’admirait.
Le chanoine s’excusa de prendre congé si vite. Tous le
raccompagnèrent jusqu’au bas du jardin. Il s’extasia encore sur
l’ampleur et l’aménité du site ; rien de plus doux que ces bois de
Buzenval et leurs feuillées vaporeuses sous le fin soleil du printemps.
Si, vers la droite, les coteaux de Saint-Cloud, les collines plus hautes
de Meudon fermaient d’une ligne sévère l’étendue, à l’est elle
semblait illimitée comme la mer ; par delà le rebord de la vallée,
Paris, au loin, s’étalait, vague autant qu’une nécropole en ruines :
des tas de pierre compacts, coupés de taches noires, de masses
boisées. Une flaque d’eau qui était la Seine, les tours d’une église,
un dôme se dégageaient du plan indistinct ; l’immensité se fondait
en brume, sans ligne d’horizon.
Le bruit des routes d’en bas grondait à peine sourdement. Des
cris d’oiseaux égayaient l’espace. Des avions invisibles peuplaient
l’éther d’un ronflement profond, tel qu’un murmure d’orgue ou la
rumeur d’une ville dans le ciel.
— Le calme des hauteurs ! exprima encore le chanoine avant de
quitter Mme Élise. Vous vivez un rêve désirable.
— N’est-ce qu’un rêve ? s’étonna-telle en lui disant adieu.
Tandis qu’elle remontait, elle s’arrêta près d’un parterre pour lier
à son tuteur une tige de rosier qui s’affaissait. Antoinette était partie
en avant ; Mme Élise suivit d’un coup d’œil Jérôme et Agnès
marchant côte à côte, tous deux souples, élancés, gracieux, elle
moins grande que lui, indolente d’allure ; et ils s’entretenaient d’un
air fraternel.
— Ces deux enfants feraient un beau couple ; mais sont-ils nés
l’un pour l’autre ?
III

En retenant sous son toit les sœurs orphelines, Mme Élise n’avait
songé d’abord qu’à un bon office d’amitié. Ensuite elle s’était dit :
« Si Agnès et Jérôme s’aimaient, j’aurais une bru exquise. »
Elle ne ressemblait pas à ces mères qui exposent aux pires
désordres la jeunesse de leur fils, abritées contre tout reproche par
le vieux sophisme : « Avant de penser au mariage, il faut être assuré
d’une situation. » Elle visait à fixer Jérôme dans un sage
attachement, prélude des noces bénies. Mais elle observait les deux
jeunes gens, en silence, sans les induire à se déclarer. De subtils
indices lui dévoilèrent, chez Agnès, une inclination que la jeune fille,
de son mieux, dissimulait. Jérôme, au contraire, ne paraissait
éprouver qu’un sentiment tranquille, proche de la simple
camaraderie. Mme Élise différait de l’interroger : « Te plaît-elle ? » Une
réponse négative l’aurait trop déçue. Elle voyait Agnès selon son
penchant à colorer d’illusions généreuses tout ce qui l’approchait.
Dans le palais enchanté qu’elle préparait à son fils elle intronisait une
Agnès ornée de multiples dons, de ceux qu’une belle-mère peut
concéder à sa belle-fille ; elle n’admettait pas qu’un simple mot vînt
abattre ses espérances.
Elle savait pourtant la fragilité des bonheurs. Le sien, après son
mariage, avait duré deux ans à peine. Elle avait vu son mari,
foudroyé par une rupture d’anévrisme, expirer entre ses bras dans
un moment où la mort était à mille lieues de leurs pensées
communes. Un de ces chocs dont l’ébranlement se prolonge toute
une vie ; certaines choses sont impossibles à recommencer, parce
qu’un souvenir affreux en défend les approches. Jeune et riche
d’ardeurs instinctives, de tendresses réprimées, courtisée, assaillie
d’hommages, elle repoussa les plus séduisants partis. Elle évita le
monde où son charme la vouait à des sollicitations. Une ferme santé,
une piété vraie l’aidèrent à soutenir ce détachement. Mais ce fut un
détachement joyeux, actif, une expansion inlassable vers les œuvres
qui lui promettaient l’oubli d’elle-même. Pendant la guerre, elle avait
assumé, à Saint-Cloud, la direction d’un hôpital. Du matin au soir,
quand elle avait assisté à la messe du Père — il la disait dans une
chambre disposée en oratoire, — entre la surveillance de son
ménage, son jardin, les lettres qu’elle écrivait à ses métayers, les
courses à Paris, des visites charitables, les travaux d’aiguille où elle
excellait, peu d’instants lui restaient pour se préoccuper de sa
personne et interroger son cœur. Elle ne lisait que durant les veillées
d’hiver ou les jours de pluie. Le Père la blâmait d’habiter trop peu
« son arrière-boutique ».
— Vous êtes Marthe jamais assise ; et nous cherchons Marie.
A quoi elle répondait :
— Je serai Marie, lorsque le Seigneur m’aura emmenée dans son
repos… Le plus tard possible, osait-elle ajouter, avec son rire
éclatant, demeuré frais et joli comme le son des girandoles de cristal
d’un lustre qu’on remue et qui scintille.
L’étrange était qu’optimiste, résolue à créer partout de la joie
autour d’elle, elle tolérât le voisinage quotidien d’un malade
quinteux, d’un homme obsédé par l’imminence des fléaux, d’un
voyant d’Apocalypse, prompt à s’exaspérer si l’on doutait de ses
prévisions. Ou plutôt il fallait, pour n’en pas être excédée, l’humeur
folâtre de Mme Élise, sa bravoure insouciante et sa bonté calme.
Son beau-frère lui rendait obscurément l’image de son mari. M.
Philippe Cormier avait été, comme l’était son frère, un vendéen de
forte race, « une tête carrée », quelqu’un de loyal, de batailleur,
d’autoritaire, même, pour parler le langage du pays,

You might also like