ebook img

Object-Oriented Programming C++ Simplified PDF

802 Pages·2017·16.3 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Object-Oriented Programming C++ Simplified

OOOOOBBBBBJJJJJEEEEECCCCCTTTTT-----OOOOORRRRRIIIIIEEEEENNNNNTTTTTEEEEEDDDDD PPPPPRRRRROOOOOGGGGGRRRRRAAAAAMMMMMMMMMMIIIIINNNNNGGGGG CCCCC++++++++++ SSSSSIIIIIMMMMMPPPPPLLLLLIIIIIFFFFFIIIIIEEEEEDDDDD OOOOOBBBBBJJJJJEEEEECCCCCTTTTT-----OOOOORRRRRIIIIIEEEEENNNNNTTTTTEEEEEDDDDD PPPPPRRRRROOOOOGGGGGRRRRRAAAAAMMMMMMMMMMIIIIINNNNNGGGGG CCCCC++++++++++ SSSSSIIIIIMMMMMPPPPPLLLLLIIIIIFFFFFIIIIIEEEEEDDDDD By HARI MOHAN PANDEY Assistant Professor Computer Engineering Department NMIMS University Mumbai (Maharashtra) (cid:0) (cid:2)(cid:3)(cid:4)(cid:5)(cid:6)(cid:7)(cid:8)(cid:4)(cid:9)(cid:10)(cid:11)(cid:8)(cid:12)(cid:4)(cid:6)(cid:3)(cid:12)(cid:6)(cid:11)(cid:13)(cid:7)(cid:6)(cid:8)(cid:8) (cid:8)(cid:33)(cid:78)(cid:0)(cid:41)(cid:77)(cid:80)(cid:82)(cid:73)(cid:78)(cid:84)(cid:0)(cid:79)(cid:70)(cid:0)(cid:44)(cid:65)(cid:88)(cid:77)(cid:73)(cid:0)(cid:48)(cid:85)(cid:66)(cid:76)(cid:73)(cid:67)(cid:65)(cid:84)(cid:73)(cid:79)(cid:78)(cid:83)(cid:0)(cid:48)(cid:86)(cid:84)(cid:14)(cid:0)(cid:44)(cid:84)(cid:68)(cid:14)(cid:9) ∑ ∑ ∑ ∑ (cid:34)E(cid:46)(cid:39)(cid:33)(cid:44)U(cid:50)U (cid:0) (cid:35)(cid:40)(cid:37)(cid:46)(cid:46)(cid:33)(cid:41) (cid:0)(cid:35)(cid:47)(cid:35)(cid:40)(cid:41)(cid:46) (cid:39)(cid:53)(cid:55)(cid:33)(cid:40)(cid:33)(cid:52)(cid:41) (cid:40)(cid:57)(cid:36)(cid:37)(cid:50)(cid:33)(cid:34)(cid:33)(cid:36) ∑ ∑ ∑ ∑ ∑ (cid:42)(cid:33)(cid:44)(cid:33)(cid:46)(cid:36)(cid:40)(cid:33)(cid:50) (cid:0)(cid:43)(cid:47)(cid:44)(cid:43)(cid:33)(cid:52)(cid:33) (cid:44)(cid:53)(cid:35)(cid:43)(cid:46)(cid:47)(cid:55) (cid:45)(cid:53)(cid:45)(cid:34)(cid:33)(cid:41) (cid:50)(cid:33)(cid:46)(cid:35)(cid:40)(cid:41) NEW DELHI ∑ (cid:41)(cid:46)(cid:36)(cid:41) (cid:33) (cid:0) (cid:53)(cid:51)(cid:33)(cid:0) (cid:39)(cid:40)(cid:33)(cid:3)(cid:3)(cid:46)(cid:3)(cid:3)(cid:33)(cid:3)(cid:3)(cid:3)(cid:0)(cid:3)(cid:3)(cid:3)(cid:3) (cid:43)(cid:37)(cid:46)(cid:57)(cid:33)(cid:0) OBJECT-ORIENTED PROGRAMMING C++ SIMPLIFIED © by Laxmi Publications (P) Ltd. All rights reserved including those of translation into other languages. In accordance with the Copyright (Amendment) Act, 2012, no part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording or otherwise. Any such act or scanning, uploading, and or electronic sharing of any part of this book without the permission of the publisher constitutes unlawful piracy and theft of the copyright holder’s intellectual property. If you would like to use material from the book (other than for review purposes), prior written permission must be obtained from the publishers. Typeset at ABRO Enterprises, Delhi First Edition: 2015 ISBN 978-93-81159-50-7 Limits of Liability/Disclaimer of Warranty: The publisher and the author make no representation or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties. The advice, strategies, and activities contained herein may not be suitable for every situation. In performing activities adult supervision must be sought. Likewise, common sense and care are essential to the conduct of any and all activities, whether described in this book or otherwise. Neither the publisher nor the author shall be liable or assumes any responsibility for any injuries or damages arising herefrom. The fact that an organization or Website if referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Website may provide or recommendations it may make. Further, readers must be aware that the Internet Websites listed in this work may have changed or disappeared between when this work was written and when it is read. All trademarks, logos or any other mark such as Vibgyor, USP, Amanda, Golden Bells, Firewall Media, Mercury, Trinity, Laxmi appear- ing in this work are trademarks and intellectual property owned by or licensed to Laxmi Publications, its subsidiaries or affiliates. Notwithstanding this disclaimer, all other names and marks mentioned in this work are the trade names, trademarks or service marks of their respective owners. & Bengaluru 080-26 75 69 30 & Chennai 044-24 34 47 26, 24 35 95 07 & Cochin 0484-237 70 04, 405 13 03 & Guwahati 0361-254 36 69, 251 38 81 s e & Hyderabad 040-27 55 53 83, 27 55 53 93 h c an & Jalandhar 0181-222 12 72 r B & Kolkata 033-22 27 43 84 Published in india by & Lucknow 0522-220 99 16 & Mumbai 022-24 91 54 15, 24 92 78 69 UNIVERSITY SCIENCE PRESS & Ranchi 0651-220 44 64 (An Imprint of Laxmi Publications Pvt.Ltd.) An ISO 9001:2008 Certified Company 113, GOLDEN HOUSE, DARYAGANJ, NEW DELHI - 110002, INDIA Telephone : 91-11-4353 2500, 4353 2501 Fax : 91-11-2325 2572, 4353 2528 C— www.laxmipublications.com [email protected] C ontents C 0 : I OOPs 1–9 HAPTER NTRODUCTION TO Structured Programming 1 Procedural Programming 3 Programming Methodology 3 Object-Oriented Programming 5 Basic Concepts of OOPs 5 Characteristics of OOPs 8 Advantages of OOPs 9 Object-Oriented Languages 9 Object-based Languages 9 C 1 : I O -O D 10–19 HAPTER NTRODUCTION OF BJECT RIENTED ESIGN 1.1 Introduction 10 1.2 Objects 11 1.3 Class and Instance 11 1.4 Polymorphism 12 1.5 Inheritance 12 1.6 Object-Oriented Analysis 12 1.7 Finding the Objects 13 1.8 Conceptual Modeling 13 1.9 Requirements Model 13 1.10 Analysis Model 13 1.11 The Design Model 13 1.12 The Implementation Model 14 1.13 Test Model 14 1.14 Object-Oriented Analysis and Design 14 1.15 The Evolution of Object Model 15 1.16 Object-Oriented Programming 15 1.17 Object-Oriented Design 15 1.18 Object-Oriented Analysis 16 (v) (vi) 1.19 Elements of Object Model 16 1.20 The Role of OOAD in the Software Life Cycle 17 1.21 OOAD Methodologies 18 1.22 Grady Booch Approach 18 C 2 : S C++ 20–46 HAPTER TARTING WITH 2.1 C++ Overview 20 2.2 C++ Character Set 20 2.3 C++ Tokens 21 2.4 Variables 25 2.5 Counting Tokens 26 2.6 Data Types 26 2.7 Qualifiers 27 2.8 Range of Data Types 28 2.9 Your First C++ Program 29 2.10 Structure of a C++ Program 33 2.11 Styles of Writing C++ Programs 35 2.12 Programming Examples 35 2.13 Ponderable Points 45 Exercise 45 C 3 : C F C++ 47–115 HAPTER EATURES OF 3.1 Introduction 47 3.2 Operators and Expressions 47 3.3 Declaring Constants 72 3.4 Type Conversion 76 3.5 Decision Making: An Introduction 77 3.6 Unconditional Branching Using Goto 92 3.7 Introduction to Looping 94 3.8 Points to Ponder 110 Exercise 112 C 4 : O R C++ 116–148 HAPTER PERATORS AND EFERENCES IN 4.1 Introduction 116 4.2 Scope Resolution Operator 116 4.3 Reference Variables 122 4.4 The Bool Data Type 127 4.5 The Operator New and Delete 129 (vii) 4.6 Malloc Vs New 140 4.7 Pointer Member Operators 140 4.8 Ponderable Points 147 Exercise 148 C 5 : F C++ 149–192 HAPTER UNCTION IN 5.1 Introduction 149 5.2 Function Declaration/Prototyping 150 5.3 The Main Function in C++ 154 5.4 Recursion 154 5.5 Call by Reference 157 5.6 Call by Reference Vs Call by Address 165 5.7 Return by Reference 165 5.8 Inline Function 169 5.9 Function Overloading 175 5.10 Function with Default Arguments 183 5.11 Ponderable Points 189 Exercise 190 C 6 : C O C++ 193–278 HAPTER LASS AND BJECTS IN 6.1 Working with Class 193 6.2 Programming Examples (Part-1) 197 6.3 Structure in C++ 215 6.4 Accessing Private Data 216 6.5 Programming Example (Part-2) 220 6.6 Passing and Returning Object 240 6.7 Array of Object 248 6.8 Friend Function 254 6.9 Static Class Members 266 6.10 Constant Member Function 274 Exercise 277 C 7 : W C D 279–333 HAPTER ORKING WITH ONSTRUCTOR AND ESTRUCTOR 7.1 Introduction 279 7.2 Constructor with Parameters 281 7.3 Implicit and Explicit Call to Constructor 283 7.4 Copy Constructor 306 7.5 Dynamic Initialization of Objects 311 (viii) 7.6 Dynamic Constructor 316 7.7 Destructor 328 7.8 Ponderable Points 332 Exercise 332 C 8 : W O O 334–392 HAPTER ORKING WITH PERATOR VERLOADING 8.1 Introduction 334 8.2 Operator Overloading with Binary Operator 336 8.3 Overloading Assignment (=) Operator 346 8.4 Overloading Unary Operators 348 8.5 Overloading Using Friend Function 358 8.6 Rules of Operator Overloading 370 8.7 Type Conversion 371 8.8 Ponderable Points 390 Exercise 391 C 9 : W I C++ 393–457 HAPTER ORKING WITH NHERITANCE IN 9.1 Introduction 393 9.2 Types of Inheritance 393 9.3 Public, Private and Protected Inheritance 398 9.4 Multiple Inheritance 424 9.5 Hierarchical Inheritance 431 9.6 Virtual Base Class 435 9.7 Constructor and Destructor in Inheritance 442 9.8 Containership 453 9.9 Ponderable Points 456 Exercise 456 C 10 : P O V F 458–510 HAPTER OINTERS TO BJECTS AND IRTUAL UNCTIONS 10.1 Pointer to Objects 458 10.2 The This Pointer 465 10.3 What is Binding in C++ ? 469 10.4 Virtual Functions 470 10.5 Working of a Virtual Function 476 10.6 Rules for Virtual Function 485 10.7 Pure Virtual Function and Abstract Class 485 10.8 Object Slicing 498

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.