9788126516582 Flipbook PDF


84 downloads 112 Views 2MB Size

Recommend Stories


Porque. PDF Created with deskpdf PDF Writer - Trial ::
Porque tu hogar empieza desde adentro. www.avilainteriores.com PDF Created with deskPDF PDF Writer - Trial :: http://www.docudesk.com Avila Interi

EMPRESAS HEADHUNTERS CHILE PDF
Get Instant Access to eBook Empresas Headhunters Chile PDF at Our Huge Library EMPRESAS HEADHUNTERS CHILE PDF ==> Download: EMPRESAS HEADHUNTERS CHIL

Story Transcript

To my loving wife Anjali and adorable daughter Namita

Foreword “Perfection in education is the manifestation of logical virtue of thought process within a human being; education and learning are the lifelong processes. True experiences based on thoughts with wisdom, perseverance ultimately, leads to wards perfection”. Computer Science is a field that keeps expanding its horizons with time. The major paradigm shift in this field has come from the inception of object-oriented approach in programming .Thus the study of object-oriented programming methodology has become essential to everyone who comes across computer science. Object-oriented programming has become the most dramatic innovation in software development in the last decade. In the recent years, object-oriented programming and object-oriented analysis and design have come up with a great importance for the computer science community. The importance of the subject is reflected from the fact the most of the universities offering courses in computer science, information technology and MCA have included this subject in their curricula at various levels. This book titled “Object-Oriented Programming in C++”, authored by Mr. Rajesh K Shukla, Head, Department of Computer Science and Engineering, Oriental Institute of Science and Technology, Bhopal, addresses the dynamism of the programming field through the clear illustration of object-oriented programming fundamentals with C++ – which is the foundation of any programming language today. Object-oriented languages, such as C++ is finding increasing popularity in the work places and newer methodologies are developing to refine object-oriented design and analysis further. C++ thus has evolved from a young, vigorous and experimental programming language into a refined and well-developed programming tool and being used on various platforms. The author, with his rich experience in the field of Computer Science and Engineering, has brought out a book that would help students with or without previous programming knowledge, to grasp concepts easily without external help. Its emphasis on programming style, subjective as well as objective areas and solved examples will certainly help the students in understanding the concept of OOP. It covers object-oriented programming methodology and its implementation in C++ under one umbrella. The book is useful not only to the students but also for C++ professionals. This book is a unique effort based on the learning capabilities of the students at various levels and wholesome in itself. Therefore it will be a valuable addition to the published material existing in the market and will also be useful for both, beginners and experienced programmers. It is with great pride and confidence that I recommend this book and hope it will be received with an enthusiastic response.

Dr P. K. Chande Former Professor – IS, IIM, Indore, Director MA – NIT, Bhopal, Director SGSITS, Indore and Corporate Head MBT

vii

viii

Prelude Object-oriented programming can trace its roots to the 1960s. As hardware and software become increasingly complex, researchers studied ways in which software quality could be maintained. Object-oriented programming was deployed in part as an attempt to address this problem by strongly emphasizing discrete units of programming logic and reusability in software. Currently it is the most common programming paradigm in software industry. Present-day software are so complex and large in size that one cannot think of designing and building them without adopting object-oriented programming principles. Any student of Computer Science who aspires to be a good programmer in today’s industry has to acquire and imbibe object-oriented programming methodologies. Particularly the C++ language has become the de facto industry standard. However, it is not so easy to develop these expertises. One requires a good introduction to the subject with several programming examples and albeit rigorous programming practice. The book “Object-Oriented Programming in C++” by Rajesh K. Shukla is the ideal book which helps a student develop the object-oriented programming skills. The book is extremely well written, lucid, with complete and systematic coverage of the subject. This exemplifies the good teaching qualities that Prof Shukla is known for among his students. The assets of the book are its numerous examples that helps to understand the nuances of object-oriented programming in C++. The book is a must read for any computer science and programming students who want to develop a career in software industry and become a top class programmer. It is an excellent expository book which can be a companion to any student in his programming endeavors. I strongly recommend it as a text book for object-oriented programming and C++.

Dr Pabitra Mitra Assistant Professor Computer Science and Engineering Indian Institute of Technology, Kharagpur

ix



Acknowledgments

First of all, I would like to thank my “guru”, guide, philosopher and mentor Dr P. K. Chande and Dr G. P. Basal for providing continuous help and guidance during the writing of this book and for their tireless efforts in completing this project in all respects. I have immense pleasure in expressing my whole hearted gratitude to all my teachers Dr J. L. Rana, Dr R. C. Jain, Dr K. R. Pardasani, Dr S. Tokekar, Dr P. Mitra, Dr Sanjeev Jain, Dr Sanjay Silakari, Dr Manish Manoria, Dr Mahesh Motwati, Dr A. K. Sachan, Dr Bhupendra Verma, Prof Sanjeev Sharma and Dr O. B. V. Ramanaih for their continuous encouragement during the preparation of this book. I also wish to express my gratitude to Brig® Iqbal Siddqui, Principal, OIST Bhopal for continuously motivating me for writing this book. How will I forget my students and my friend for their invaluable suggestion and critical review of the manuscript and for inspiring me to write this book? I should not forget Yogesh Kashive for his continuous support. Thanks to all of you. I am grateful to Paras Bansal, Associate Publisher Wiley India Pvt. Ltd. who found the time to return my phone calls and to keep my spirit up. My deep sense of appreciation to the editorial group of Wiley India Pvt. Ltd. especially to Meenakshi Sehrawat and Sruthi Guru who have been enthusiastic and helpful in giving fruitful comments and suggestions while reviewing the manuscript. I would be failing in my duty, if I do not say a word of thanks to my father, my mother, my wife, my daughter, my brother for all educative, effective, pleasurable and sincere advice. Last but not the least, I would like to thank the whole management of OGI, Directors, Principles and all employees of OGI Group. Rajesh K. Shukla

xi

xii

Preface The study of Object-Oriented Programming is an essential part of every undergraduate and postgraduate program in Computer Science. I have been teaching “OOPs” and related course over the past 10 years and during teaching I have found that considerable amount of time was spent in teaching programming techniques because the students have not had sufficient exposure to programming. Moreover, good and relevant learning material in the form of textbooks or manuals are also not available to the students. I felt the need for a balanced book on the subject; in fact this is the main aim behind writing this book. This book aims to fill up this gap and meets the needs and requirements of students. This book aims to cater to beginners who love to learn C++ and Object-Oriented Programming under same umbrella. This book is suitable for self study because of clear explanation of the topics, uniformity in presentation, concepts are illustrated through numerous examples and all programs in the text are tested. Each chapter is followed by, multiple-choice questions, review questions and programming assignments to test the students’ performance. The book concludes with mixed true and false questions related to the whole book and the model question papers. Efforts have been made to cover the topics in the simplest possible way without losing its qualities. The text is useful to C++ professionals and programmers as well as students of any branch of engineering of graduate or postgraduate courses. This book has a logically designed course structure. Each module is suitable divided into units of major subtopics. Each unit has a uniform structure in presentation starting with learning objectives, introduction, moving through illustrations, types, operations, concept check, summary, multiple-choice questions, review questions and programming assignments. There are numerous examples for exercise and sample programs to prepare you for the examination. Assistance to all programming assignment questions are also given at the end of each chapter. Objective questions for different competitive examination are also given. Primarily written as a book for self learning, students will find this as a best guide for their examination also. The chapters in the book are organized in increasing degree of complexity. Chapter 1 introduces the procedure-oriented programming approach and its comparison with OOP that will help the students in understanding the concept of OOP. Chapter 2 deals with the elementary concept of C++ so after reading this chapter students can start writing small programs. Chapter 3 covers function which is one of the important parts of the class. This chapter gives a complete idea of functions needed in subsequent chapters. Chapter 4 explores the user-defined data type – an array in very effective manner. An array can contain items of similar kinds. Chapter 5 covers another user-defined data type – structure along with union, bit fields. This chapter will build the foundation for class and object as discussed in Chapter 7. Chapter 6 deals with one of the difficult part of the programming languages called pointers in a very simple and easy to understand manner. Chapter 7 focuses on a class: the foundation of object-oriented programming. Chapter 8 explores the initialization technique and de-allocation of memory for objects. Chapter 9 introduces the inheritance which is used to create the relationships among the objects. Chapter 10 covers polymorphism and virtual functions. Chapter 11 deals with the advanced topics of C++ like templates and exception handling. Chapter 12 deals with description of stream and files. Chapter 13 covers the graphics programming in C++. Chapter 14 covers preprocessor directives and I/O, C++ stream. Rajesh K. Shukla

xiii

xiv

Contents

Foreword

vii

Prelude

ix

Acknowledgments

xi

Preface

xiii

1  Fundamentals of Object-Oriented Programming

1



Learning Objectives

1



1.1

Procedure-Oriented Programming Concepts

1



1.2

Object-Oriented Programming Concepts

2

1.3 Characteristics or Features of OOPs Class Object Encapsulation Data Abstraction Inheritance Polymorphism Data Hiding

4



1.4

9



1.5 Types of Objects

Modeling Real-World Objects

9

1.6 Kinds of Relationships Association Aggregation or “A-Part-Of ” Relationship Specialization and Generalization (Is-A or Is-A-Kind-Of Relationship)

10

1.7 Class and Object Diagrams Class Diagram Object Diagram

13

xv

Get in touch

Social

© Copyright 2013 - 2024 MYDOKUMENT.COM - All rights reserved.