Object oriented programming with C++, 2nd Edition

Book description

This fully revised and indispensable edition of Object-Oriented Programming with C++ provides a sound appreciation of the fundamentals and syntax of the language, as well as of various concepts and their applicability in real-life problems. Emphasis has been laid on the reusability of code in object-oriented programming and how the concepts of class, objects, inheritance, polymorphism, friend functions and operator overloading are all geared to make the development and maintenance of applications easy, convenient and economical.

Table of contents

  1. Cover (1/2)
  2. Cover (2/2)
  3. Contents (1/2)
  4. Contents (2/2)
  5. Foreword
  6. Preface to the Second Edition
  7. Preface to the First Edition
  8. Chapter 1: Introduction to Computers and Computing
    1. 1.1 Hardware
      1. Operating Systems
    2. 1.2 Evolution of Programming Languages
    3. 1.3 Brief History of C++
    4. 1.4 C++ as a Superset of C Programming Language
    5. 1.5 To Run a Program
    6. 1.6 An Informal Introduction to C++ Program
    7. Summary
  9. Chapter 2: Moving from C to C++I
    1. 2.1 Fundamentals
      1. 2.1.1 Comments
      2. 2.1.2 Character set
      3. 2.1.3 Identifiers and keywords
    2. 2.2 Data Types
      1. 2.2.1 Simple data types
      2. 2.2.2 Aggregate data types
      3. 2.2.3 Pointer data type
      4. 2.2.4 Enumerated data type
      5. 2.2.5 Type reference
      6. 2.2.6 Type void
    3. 2.3 Constants and Variables Declarations
    4. 2.4 Operators and Expressions (1/2)
    5. 2.4 Operators and Expressions (2/2)
    6. 2.5 Library Functions
    7. 2.6 Statements
    8. 2.7 Pre-processor Directives
    9. 2.8 C++ is a Block-Structured Language
    10. 2.9 Typedef Facility
    11. 2.10 Simple Input–Output
      1. 2.10.1 Input–output with cin and cout
      2. 2.10.2 Console input–output
    12. 2.11 Control Statements
      1. 2.11.1 if statement
      2. 2.11.2 Switch statement
    13. 2.12 Iteration Statements
      1. 2.12.1 for statement
      2. 2.12.2 while statement
      3. 2.12.3 do-while statement
      4. 2.12.4 break and continue statements
      5. 2.12.5 goto statement
      6. 2.12.6 Comparison of all the three constructs
    14. 2.13 End of Chapter Programs
      1. 2.13.1 Sum of series
      2. 2.13.2 Accuracy of type float is limited!
      3. 2.13.3 Prime number
    15. 2.14 Flow Charts and Decision Tables
    16. For Advanced Readers
    17. Summary
    18. Exercises
  10. Chapter 3: Moving from C to C++ II
    1. 3.1 Introduction to Functions
    2. 3.2 Parameter Passing
      1. 3.2.1 call by value
      2. 3.2.2 GCD and LCM
      3. 3.2.3 call by reference – new style
      4. 3.2.4 call by reference – old style
      5. 3.2.5 Rules of parameter passing
      6. 3.2.6 Use of const parameter
    3. 3.3 Local Versus Global Variables
    4. 3.4 Function Overloading
    5. 3.5 Functions with Default Arguments
    6. 3.6 inline Functions
    7. 3.7 Storage Classes
      1. 3.7.1 auto
      2. 3.7.2 Keyword register
      3. 3.7.3 Keyword static
      4. 3.7.4 Keyword extern
    8. 3.8 Recursion
    9. 3.9 Scope Rules
    10. 3.10 Arrays
      1. 3.10.1 Introduction
      2. 3.10.2 Array as function parameter
      3. 3.10.3 Arrays with multiple dimension
    11. 3.11 Structures
      1. 3.11.1 Assignment of structure variables
      2. 3.11.2 Using structure as function parameters
      3. 3.11.3 Pointer to structures
    12. 3.12 Union
      1. 3.12.1 Defining an union
      2. 3.12.2 Working with union
      3. 3.12.3 Anonymous union
    13. 3.13 Line Splicing
    14. 3.14 Command Line Arguments
    15. 3.15 Multi File Programs
    16. 3.16 Difference Between C and C++
      1. 3.16.1 Major differences
      2. 3.16.2 Minor differences
    17. 3.17 End of Chapter Programs
    18. For Advanced Readers
    19. Summary
    20. Exercises
  11. Chapter 4: Object Orientation: An Introduction
    1. 4.1 Programming Paradigms
      1. 4.1.1 Spectrum of computer applications
      2. 4.1.2 Bird’s-eye view of programming paradigms
    2. 4.2 Popular Recent Paradigms
      1. 4.2.1 Procedural programming
      2. 4.2.2 Object-oriented programming
      3. 4.2.3 Programming language C++
      4. 4.2.4 Programming language JAVA
      5. 4.2.5 Procedural programming vs. object-oriented programming
    3. 4.3 An Introduction to Object Orientation
      1. 4.3.1 From structures to objects
    4. 4.4 Features of Object-Oriented Language
    5. 4.5 Benefits of Object-Oriented Programming
    6. 4.6 Writing Large Programs
    7. Summary
    8. Multiple Choice Questions and Answers
    9. Exercises
  12. Chapter 5: Classes and Objects
    1. 5.1 Introduction
    2. 5.2 Data Hiding and Encapsulation
      1. 5.2.1 Private and public data members
    3. 5.3 Member Functions
      1. 5.3.1 Scope resolution operator
    4. 5.4 Accessing Class Members
    5. 5.5 Some Short Questions and Answers I
    6. 5.6 Using Pointers for Objects
    7. 5.7 Objects as Function Parameters
    8. 5.8 Some Short Questions and Answers II
    9. 5.9 Inline Functions (Within a Class)
    10. 5.10 Static Data Members and Methods
      1. 5.10.1 Static data member
      2. 5.10.2 Static methods
    11. 5.11 Friend Functions
    12. 5.12 Friend Classes
    13. 5.13 Access Specifier Protected
    14. 5.14 Ideal Class Definition
    15. 5.15 End of Chapter Programs
      1. 5.15.1 Timer application
      2. 5.15.2 Complex numbers
      3. 5.15.3 Parameter passing by reference (C style)
    16. For Advanced Readers
    17. Summary
    18. Multiple Choice Questions and Answers
    19. Exercises
  13. Chapter 6: Object Initialization and Cleanup
    1. 6.1 Introduction
    2. 6.2 Constructors
    3. 6.3 Parameterized Constructor
    4. 6.4 Pointer “this”
    5. 6.5 Constructor Overloading
    6. 6.6 Default Constructor
    7. 6.7 Constructors with Default Arguments
    8. 6.8 Copy Constructor
    9. 6.9 Copy Initialization
    10. 6.10 Array of Objects
      1. 6.10.1 Array of objects – without pointers
      2. 6.10.2 Array of objects – With pointer
    11. 6.11 Destructors
    12. 6.12 End of Chapter Programs
      1. 6.12.1 Initializer list
    13. For Advanced Readers
    14. Summary
    15. Multiple Choice Questions and Answers
    16. Exercises
  14. Chapter 7: Operator Overloading
    1. 7.1 Introduction
    2. 7.2 Unary Operator Overloading
    3. 7.3 Binary Operator Overloading
      1. 7.3.1 Case 1: object + object
      2. 7.3.2 Case 2: object + basic data type
      3. 7.3.3 Case 3: basic data type + object
    4. 7.4 Friend Functions in Operator Overloading
      1. 7.4.1 Binary operator overloading [case 3]
      2. 7.4.2 Binary operator overloading [case 1]
    5. 7.5 Overloading of Increment Operator
    6. 7.6 Conversion Function
    7. 7.7 End of Chapter Programs
      1. 7.7.1 Overloading of assignment operator [case 1]
      2. 7.7.2 Overloading << operator
      3. 7.7.3 Expression with unary as well as binary overloaded operators
      4. 7.7.4 Class polar
      5. 7.7.5 Rational numbers
    8. For Advanced Readers
    9. Summary
    10. Multiple Choice Questions and Answers
    11. Exercises
  15. Chapter 8: Strings
    1. 8.1 Introduction
    2. 8.2 Working with Strings
      1. 8.2.1 Reading a string
      2. 8.2.2 Writing a string
      3. 8.2.3 Comparing strings
      4. 8.2.4 Copying one string into other
      5. 8.2.5 Length of a string
      6. 8.2.6 Concatenation of strings
    3. 8.3 Useful Functions for Operating on Strings
    4. 8.4 Simple String Programs
      1. 8.4.1 Capitalize first character
      2. 8.4.2 Reading a string containing blank
      3. 8.4.3 Removing return from a string
      4. 8.4.4 Sorting strings
      5. 8.4.5 Printing Strings with Field Specifications
      6. 8.4.6 Copying strings
    5. 8.5 Our Own Strings
    6. 8.6 Constructors for Type String
    7. 8.7 Interactive Constructor for Class String
    8. 8.8 Operator Overloading with Class String
    9. For Advanced Readers
    10. Summary
    11. Multiple Choice Questions and Answers
    12. Exercises
  16. Chapter 9: Inheritance I
    1. 9.1 Introduction
    2. 9.2 Derived and Base Class
    3. 9.3 Public Derivation
      1. 9.3.1 Public members of base class
      2. 9.3.2 Private members of base class
      3. 9.3.3 Protected members of base class
    4. 9.4 Private Derivation
    5. 9.5 Protected Derivation
    6. 9.6 Function Overriding
      1. 9.6.1 Overriding and overloading
    7. 9.7 Base and Derived Class Constructors
    8. 9.8 End of Chapter Programs
      1. 9.8.1 Working with private derivation
      2. 9.8.2 Program on students and their performance
      3. 9.8.3 Function overriding: different signature
    9. For Advanced Readers
    10. Summary
    11. Multiple Choice Questions and Answers
    12. Exercises
  17. Chapter 10: Inheritance II
    1. 10.1 Multiple Inheritance
    2. 10.2 Hierarchical Inheritance
    3. 10.3 Multilevel Inheritance
    4. 10.4 Hybrid Inheritance
    5. 10.5 A Multipath Inheritance
    6. 10.6 Virtual Base Class
    7. 10.7 Constructors for Virtual Base Classes
    8. 10.8 Classification of Inheritance
    9. 10.9 Relationships
      1. 10.9.1 is–a Relationship
      2. 10.9.2 has–a Relationship
    10. 10.10 Practical Class Definition
    11. For Advanced Readers
    12. Summary
    13. Multiple Choice Questions and Answers
    14. Exercises
  18. Chapter 11: Input/Output
    1. 11.1 Introduction
    2. 11.2 Stream I/O Classes
    3. 11.3 Format-free Input
    4. 11.4 Formatted Input
    5. 11.5 Format-free Output
    6. 11.6 Formatted Output
      1. 11.6.1 Writing integers
      2. 11.6.2 Writing float
      3. 11.6.3 Writing structures and objects
    7. 11.7 The Manipulators
      1. 11.7.1 Manipulators for reading integers
      2. 11.7.2 Manipulators for writing integers
      3. 11.7.3 Manipulators for writing floats
    8. 11.8 Summary of Manipulators
    9. 11.9 Our Own Manipulators
    10. 11.10 Miscellaneous Functions
    11. For Advanced Readers
    12. Summary
    13. Multiple Choice Questions and Answers
    14. Exercises
  19. Chapter 12: Pointers
    1. 12.1 Introduction
    2. 12.2 The & (AND) Operator
    3. 12.3 The * Operator
    4. 12.4 Pointers and Arrays
    5. 12.5 Pointer Arithmetic
    6. 12.6 Pointer to Void
    7. 12.7 Pointer to Function
    8. 12.8 Dynamic Memory Allocation
      1. 12.8.1 Free Store
    9. 12.9 Operators new and delete
      1. 12.9.1 Operator new
      2. 12.9.2 Operator delete
    10. 12.10 One Dimensional Arrays Using Pointers
    11. 12.11 Two Dimensional Arrays Using Pointers
    12. 12.12 Pointers to User Defined Data Types
      1. 12.12.1 Array of pointers (to objects)
    13. 12.13 Advantages and Disadvantages of Pointers
    14. 12.14 End of Chapter Programs
      1. 12.14.1 Class Vector
      2. 12.14.2 Comparison of pointers
      3. 12.14.3 Study of NULL
    15. For Advanced Readers
    16. Summary
    17. Multiple Choice Questions and Answers
    18. Exercises
  20. Chapter 13: Polymorphism
    1. 13.1 Introduction
    2. 13.2 Compile Time Polymorphism
      1. 13.2.1 Polymorphism with ordinary1 objects
      2. 13.2.2 Polymorphism with dynamic objects2
      3. 13.2.3 Early binding
      4. 13.2.4 Function overriding
    3. 13.3 Pointing to Derived Class Objects
      1. 13.3.1 Demo program: The Twist
    4. 13.4 Virtual Functions
      1. 13.4.1 Need for virtual functions
      2. 13.4.2 Declaring function virtual
    5. 13.5 Run Time Polymorphism
      1. 13.5.1 Run time polymorphism in action
    6. 13.6 Pure Virtual Functions
    7. 13.7 Abstract Classes
    8. 13.8 The Climax: Array of Derived Class Objects
    9. 13.9 Implicit Derived-Class Object to Base-Class Object Conversion
    10. 13.10 End of Chapter Programs
      1. 13.10.1 A class with virtual function can be instantiated
      2. 13.10.2 Class shape
    11. For Advanced Readers
    12. Summary
    13. Multiple Choice Questions and Answers
    14. Exercises
  21. Chapter 14: File Handling
    1. 14.1 Introduction
    2. 14.2 Why Files?
    3. 14.3 Basic File Types
    4. 14.4 Text Files
      1. 14.4.1 Reading and writing text files
      2. 14.4.2 Reading numeric data from text file
      3. 14.4.3 Writing data to text file
      4. 14.4.4 Reading and writing strings
      5. 14.4.5 Use of function eof() in reading text files
    5. 14.5 Binary Files
      1. 14.5.1 Reading and writing binary files: file of Integer
      2. 14.5.2 Binary files for object
    6. 14.6 File Opening Modes
    7. 14.7 Classification of Files
      1. 14.7.1 File pointer
      2. 14.7.2 Sequentially accessing binary file
      3. 14.7.3 Direct access files
    8. 14.8 Direct Access Files: Simultaneous Read Write
    9. 14.9 Files and Stream Classes
    10. 14.10 Errors and Error Handling in File Operation
    11. 14.11 In the Days of C
    12. 14.12 End of Chapter Programs
      1. 14.12.1 Encrypt a file
      2. 14.12.2 Splitting and joining a large file
    13. For Advanced Readers
    14. Summary
    15. Multiple Choice Questions and Answers
    16. Exercises
  22. Chapter 15: Templates
    1. 15.1 Introduction to Template
    2. 15.2 Function Template
      1. 15.2.1 Overloading of template functions
    3. 15.3 Class Templates
      1. 15.3.1 Template class with static members
      2. 15.3.2 Template class with friend function
      3. 15.3.3 Template class and inheritance
    4. 15.4 Comparison Between Class Templates and Function Templates
    5. 15.5 Standard Template Library
    6. 15.6 End of Chapter Programs
      1. 15.6.1 Array with bounds checking I
      2. 15.6.2 Array with bounds checking II
      3. 15.6.3 Static members in class template
      4. 15.6.4 Class template and inheritance
    7. For Advanced Readers
    8. Summary
    9. Multiple Choice Questions and Answers
    10. Exercises
  23. Chapter 16: Miscellaneous Topics
    1. 16.1 “const” The Protector!
      1. 16.1.1 Pointer to constant
      2. 16.1.2 Constant pointer
      3. 16.1.3 Constant pointer to constant
    2. 16.2 “const” with Class Objects
      1. 16.2.1 “const” Class object
      2. 16.2.2 “const” With data members
      3. 16.2.3 “const” With methods
    3. 16.3 Conditional Compilation
    4. 16.4 Functions with Variable Arguments
    5. 16.5 Bit Manipulation
      1. 16.5.1 Getting and setting a bit
      2. 16.5.2 Getting group of bits
      3. 16.5.3 A case study – ios flags
      4. 16.5.4 Data encryption by bit manipulation
    6. 16.6 Scope Resolution Operator as Unary Operator
    7. 16.7 Pointers to Members
    8. For Advanced Readers
    9. Summary
    10. Multiple Choice Questions and Answers
    11. Exercises
  24. Chapter 17: Graphics and Animation
    1. 17.1 Introduction
    2. 17.2 Graphics Initialization
    3. 17.3 The Screen in Graphics Mode
    4. 17.4 Uniform Look and Feel with Object Orientation
    5. 17.5 Rotating Phasor and Sinusoidal Wave
    6. 17.6 Periodic Waveform Generation Using Fourier Series
      1. 17.6.1 Square wave generation using fourier series
      2. 17.6.2 Triangular wave using fourier series
    7. 17.7 Monte Carlo Method
    8. 17.8 Storing Image on the Disk
    9. 17.9 Animation
    10. 17.10 Using a Mouse
    11. 17.11 Tiger by the Tail – A VB Form
    12. 17.12 Summary of Graphics Functions and Constants
    13. For Advanced Readers
    14. Summary
    15. Exercises
  25. Chapter 18: Exception Handling
    1. 18.1 Introduction
    2. 18.2 Errors and Error Handling: Life Before Exceptions
    3. 18.3 Exception Handling Building Blocks
      1. 18.3.1 throw statement
      2. 18.3.2 try block
      3. 18.3.3 catch clause
    4. 18.4 Working of Exception Handling Mechanism
      1. 18.4.1 Multiple catch clauses
    5. 18.5 Catching all Exceptions
    6. 18.6 Object as Exception
    7. 18.7 Re-throwing an Exception
    8. 18.8 Exception Specification
    9. 18.9 Stack Unwinding
    10. 18.10 Exceptions in Constructors and Destructors
    11. 18.11 Exceptions and Inheritance
    12. 18.12 Class Exception
    13. For Advanced Readers
    14. Summary
    15. Multiple Choice Questions and Answers
    16. Exercises
  26. Chapter 19: Advanced Topics from ANSI/ISO C++
    1. 19.1 New Type String
      1. 19.1.1 Declaring and constructing a string
      2. 19.1.2 Reading a string
      3. 19.1.3 Writing a string
      4. 19.1.4 Copying one string into another
      5. 19.1.5 Comparing strings
      6. 19.1.6 Inspecting a character
      7. 19.1.7 Searching and inserting
      8. 19.1.8 Concatenation of strings
    2. 19.2 Type Bool
    3. 19.3 Standard Template Library (STL)
    4. 19.4 Container Classes
      1. 19.4.1 List
      2. 19.4.2 Vector
      3. 19.4.3 Set
      4. 19.4.4 Map
      5. 19.4.5 Stack
    5. 19.5 Iterators
    6. 19.6 Algorithms
      1. 19.6.1 Function objects
    7. 19.7 Taxonomy of Classes
    8. 19.8 Type Casting Operators
      1. 19.8.1 static_cast operator
      2. 19.8.2 dynamic_cast operator
      3. 19.8.3 reinterpret_cast operator
      4. 19.8.4 const_cast operator
    9. 19.9 Run Time Type Information RTTI
      1. 19.9.1 “typeid” operator
    10. 19.10 Remaining Topics
      1. 19.10.1 Namespace
      2. 19.10.2 Keyword mutable
      3. 19.10.3 Keyword explicit
    11. For Advanced Readers
    12. Summary
    13. Multiple Choice Questions and Answers
    14. Exercises
  27. Chapter 20: Towards Better Programming
    1. 20.1 Introduction
    2. 20.2 External Characteristics
      1. 20.2.1 Formatting the source code
      2. 20.2.2 Selection of appropriate identifiers
      3. 20.2.3 Liberal use of comments
    3. 20.3 Internal Characteristics
      1. 20.3.1 Using principles of software engineering
      2. 20.3.2 Coding discipline
    4. Summary
    5. Exercises
  28. Chapter 21: Collection of Programs
    1. 21.1 Matrices
      1. 21.1.1 Diagonal matrix
      2. 21.1.2 Symmetrical matrix
    2. 21.2 Statistics
      1. 21.2.1 Standard deviation and variance
      2. 21.2.2 Curve fitting (straight line)
    3. 21.3 Account and Finance
      1. 21.3.1 Bank account
      2. 21.3.2 Housing loan
      3. 21.3.3 Converting currency
      4. 21.3.4 Savings bank account: Use of ATM
    4. 21.4 Dynamic Data Structures
      1. 21.4.1. Linked list
      2. 21.4.2 Creating a linked list
      3. 21.4.3 Creating a linked list where data is in same order as that of its arrival
      4. 21.4.4 Searching a linked list
      5. 21.4.5 Inserting a node in a linked list
      6. 21.4.6 Simulation of stack
      7. 21.4.7 Binary search tree
      8. 21.4.8 Removal of duplicates
    5. 21.5 Text Window
      1. 21.5.1 Using console I/O for three window system
    6. 21.6 Astrology
      1. 21.6.1 Simple introduction to astrology
      2. 21.6.2 Lord of ascendant (1/2)
      3. 21.6.2 Lord of ascendant (2/2)
    7. 21.7 Graphics
      1. 21.7.1 Bit map editor
      2. 21.7.2 Fabric design
      3. 21.7.3 Game of bricks
    8. Summary
    9. Exercises
  29. Chapter 22: OOAD with Snake and Ladder
    1. 22.1 Object-Oriented Analysis (OOA)
    2. 22.2 Object-Oriented Design (OOD)
    3. 22.3 Analysis of Snake and Ladder Game
      1. 22.3.1 Problem specification
      2. 22.3.2 Requirement analysis
      3. 22.3.3 Final analysis
    4. 22.4 The Design
      1. 22.4.1 Design of classes
      2. 22.4.2 Interaction
      3. 22.4.3 Sequence of actions (1/3)
      4. 22.4.3 Sequence of actions (2/3)
      5. 22.4.3 Sequence of actions (3/3)
  30. Chapter 23: Rule Book of C++ (1/2)
  31. Chapter 23: Rule Book of C++ (2/2)
  32. Chapter 24: Objects Library
    1. 24.1 Money Matter
    2. 24.2 Numbers
    3. 24.3 Date and Time
    4. 24.4 Geometry
    5. 24.5 Persons
    6. 24.6 Books
    7. 24.7 Strings
    8. 24.8 Living Things
    9. 24.9 Dynamic Data Structures
    10. 24.10 Rail Ticket
    11. 24.11 Timer
    12. 24.12 Template Based Classes
    13. 24.13 Playing Cards
    14. 24.14 Others
  33. Appendices
    1. Appendix A: Keywords in C++
    2. Appendix B: Precedence of Operators
    3. Appendix C: List of Turbo C++ Header Files
    4. Appendix D: Flags and Manipulators
    5. Appendix E: Turbo C ++ 3.0 Environment (1/2)
    6. Appendix E: Turbo C ++ 3.0 Environment (2/2)
    7. Appendix F: Console Input–Output
    8. Appendix G: Simple C Style input–output (1/2)
    9. Appendix G: Simple C Style input–output (2/2)
    10. Appendix H: G++ Compiler and Codeblocks IDE
    11. Appendix I: Standard Library
    12. Appendix J: Mini Projects (1/2)
    13. Appendix J: Mini Projects (2/2)
  34. Glossary (1/10)
  35. Glossary (2/10)
  36. Glossary (3/10)
  37. Glossary (4/10)
  38. Glossary (5/10)
  39. Glossary (6/10)
  40. Glossary (7/10)
  41. Glossary (8/10)
  42. Glossary (9/10)
  43. Glossary (10/10)
  44. Bibliography
  45. Index (1/2)
  46. Index (2/2)

Product information

  • Title: Object oriented programming with C++, 2nd Edition
  • Author(s): Bhave, Patekar
  • Release date: April 2024
  • Publisher(s): Pearson India
  • ISBN: 9781299445420