Programming in C++, 2nd Edition

Book description

The revised and updated version of the student-friendly, practical and example-driven book, Programming in C++, continues to give its readers a solid background and a learning platform to the fundamentals of C++. This comprehensive book, enriched with illustrations and a number of solved programs, will help the students to master this subject.

Table of contents

  1. Cover
  2. Title Page
  3. Brief Contents
  4. Contents
  5. About the Author
  6. Dedication
  7. Preface
  8. Chapter 1: Introduction to C++
    1. 1.1 Differences between C and C++
    2. 1.2 Evolution of C++
    3. 1.3 The ANSI Standard
    4. 1.4 The Object Oriented Technology
    5. 1.5 Disadvantage of Conventional Programming
    6. 1.6 Programming Paradigms
    7. 1.7 Preface to Object Oriented Programming
    8. 1.8 Key Concepts of Object Oriented Programming
    9. 1.9 Advantages of OOP
    10. 1.10 Object Oriented Languages
    11. 1.11 Usage of OOP
    12. 1.12 Usage of C++
    13. Summary
    14. Exercises
  9. Chapter 2: Basics of C++
    1. 2.1 Introduction
    2. 2.2 Steps to Create and Execute a C++ Program
    3. 2.3 Flowchart for Creating a Source File, Compiling, Linking and Executing in C++
    4. 2.4 C++ Environments
    5. 2.5 Typical C++ Environment (Borland C++)
    6. 2.6 Structure of a C++ Program
    7. 2.7 Illustrative Simple Program in C++ without Class
    8. 2.8 Header Files and Libraries
    9. Summary
    10. Exercises
  10. Chapter 3: Input and Output in C++
    1. 3.1 Introduction
    2. 3.2 Streams in C++ and Stream Classes
    3. 3.3 Pre-defined Streams
    4. 3.4 Buffering
    5. 3.5 Stream Classes
    6. 3.6 Formatted and Unformatted Data
    7. 3.7 Unformatted Console I/O Operations
    8. 3.8 Type Casting with the cout Statement
    9. 3.9 Member Functions of the istream Class
    10. 3.10 Formatted Console I/O Operations
    11. 3.11 Bit Fields
    12. 3.12 Flags without Bit Fields
    13. 3.13 Manipulators
    14. 3.14 User-defined Manipulators
    15. 3.15 Manipulator with One Parameter
    16. 3.16 Manipulators with Multiple Parameters
    17. 3.17 More Programs
    18. Summary
    19. Exercises
  11. Chapter 4: C++ Declarations
    1. 4.1 Introduction
    2. 4.2 Tokens
    3. 4.3 Variable Declaration and Initialization
    4. 4.4 Data Types in C++
    5. 4.5 Operators in C and C++
    6. 4.6 Scope Access Operator
    7. 4.7 Namespace
    8. 4.8 Memory Management Operators
    9. 4.9 Comments
    10. 4.10 Comma Operator
    11. 4.11 Comma in Place of Curly Braces
    12. 4.12 More Programs
    13. Summary
    14. Exercises
  12. Chapter 5: Decision Statements
    1. 5.1 Introduction
    2. 5.2 The if Statement
    3. 5.3 Multiple ifs
    4. 5.4 The if-else Statement
    5. 5.5 Nested if-else Statements
    6. 5.6 The else-if Ladder
    7. 5.7 Unconditional Control Transfer Statements
    8. 5.8 The switch Statement
    9. 5.9 Nested switch case
    10. Summary
    11. Exercises
  13. Chapter 6: Control Loop Structures
    1. 6.1 Introduction
    2. 6.2 What Is a Loop?
    3. 6.3 The for Loop
    4. 6.4 Nested for Loops
    5. 6.5 The while Loop
    6. 6.6 The do-while Loop
    7. 6.7 The do-while Statement with while Loop
    8. 6.8 More Programs
    9. Summary
    10. Exercises
  14. Chapter 7: Functions in C++
    1. 7.1 Introduction
    2. 7.2 Parts of a Function
    3. 7.3 Passing Arguments
    4. 7.4 Lvalues and Rvalues
    5. 7.5 Return by Reference
    6. 7.6 Returning More Values by Reference
    7. 7.7 Default Arguments
    8. 7.8 const Arguments
    9. 7.9 Inputting Default Arguments
    10. 7.10 Inline Functions
    11. 7.11 Function Overloading
    12. 7.12 Principles of Function Overloading
    13. 7.13 Precautions with Function Overloading
    14. 7.14 Recursion
    15. 7.15 Library Functions
    16. 7.16 More Programs
    17. Summary
    18. Exercises
  15. Chapter 8: Classes and Objects
    1. 8.1 Introduction
    2. 8.2 Structure in C
    3. 8.3 Structure in C++
    4. 8.4 Classes in C++
    5. 8.5 Declaring Objects
    6. 8.6 The public Keyword
    7. 8.7 The private Keyword
    8. 8.8 The protected Keyword
    9. 8.9 Access Specifiers and Their Scope
    10. 8.10 Defining Member Functions
    11. 8.11 Characteristics of Member Functions
    12. 8.12 Outside Member Function as Inline
    13. 8.13 Rules for Inline Functions
    14. 8.14 Data Hiding or Encapsulation
    15. 8.15 Classes, Objects, and Memory
    16. 8.16 static Member Variables
    17. 8.17 static Member Functions
    18. 8.18 static Object
    19. 8.19 Array of Objects
    20. 8.20 Objects as Function Arguments
    21. 8.21 friend Functions
    22. 8.22 The const Member Functions
    23. 8.23 The Volatile Member Function
    24. 8.24 Recursive Member Function
    25. 8.25 Local Classes
    26. 8.26 empty, static, and const Classes
    27. 8.27 Member Function and Non-member Function
    28. 8.28 The main() Function as a Member Function
    29. 8.29 Overloading Member Functions
    30. 8.30 Overloading main() Functions
    31. 8.31 The main(), Member Function, and Indirect Recursion
    32. 8.32 Bit Fields and Classes
    33. 8.33 Nested Class
    34. 8.34 More Programs
    35. Summary
    36. Exercises
  16. Chapter 9: Constructors and Destructors
    1. 9.1 Introduction
    2. 9.2 Constructors and Destructors
    3. 9.3 Characteristics of Constructors and Destructors
    4. 9.4 Applications with Constructors
    5. 9.5 Constructors with Arguments (Parameterized Constructor)
    6. 9.6 Overloading Constructors (Multiple Constructors)
    7. 9.7 Array of Objects Using Constructors
    8. 9.8 Constructors with Default Arguments
    9. 9.9 Copy Constructors
    10. 9.10 The const Objects
    11. 9.11 Destructors
    12. 9.12 Calling Constructors and Destructors
    13. 9.13 Qualifier and Nested Classes
    14. 9.14 Anonymous Objects
    15. 9.15 Private Constructors and Destructors
    16. 9.16 Dynamic Initialization Using Constructors
    17. 9.17 Dynamic Operators and Constructors
    18. 9.18 main() as a Constructor and Destructor
    19. 9.19 Recursive Constructors
    20. 9.20 Program Execution Before main()
    21. 9.21 Constructor and Destructor with Static Members
    22. 9.22 Local Versus Global Object
    23. 9.23 More Programs
    24. Summary
    25. Exercises
  17. Chapter 10: Operator Overloading and Type Conversion
    1. 10.1 Introduction
    2. 10.2 The Keyword Operator
    3. 10.3 Overloading Unary Operators
    4. 10.4 Operator Return Type
    5. 10.5 Constraint on Increment and Decrement Operators
    6. 10.6 Overloading Binary Operators
    7. 10.7 Overloading with friend Function
    8. 10.8 Overloading Assignment Operator (=)
    9. 10.9 Type Conversion
    10. 10.10 Rules for Overloading Operators
    11. 10.11 One-Argument Constructor and Operator Function
    12. 10.12 Overloading Stream Operators
    13. 10.13 More Programs
    14. Summary
    15. Exercises
  18. Chapter 11: Inheritance
    1. 11.1 Introduction
    2. 11.2 Reusability
    3. 11.3 Access Specifiers and Simple Inheritance
    4. 11.4 Protected Data with Private Inheritance
    5. 11.5 Types of Inheritance
    6. 11.6 Single Inheritance
    7. 11.7 Multilevel Inheritance
    8. 11.8 Multiple Inheritance
    9. 11.9 Hierarchical Inheritance
    10. 11.10 Hybrid Inheritance
    11. 11.11 Multipath Inheritance
    12. 11.12 Virtual Base Classes
    13. 11.13 Constructors, Destructors, and Inheritance
    14. 11.14 Object as a Class Member
    15. 11.15 Abstract Classes
    16. 11.16 Qualifier Classes and Inheritance
    17. 11.17 Constructors in Derived Class
    18. 11.18 Pointers and Inheritance
    19. 11.19 Overloading Member Function
    20. 11.20 Advantages of Inheritance
    21. 11.21 Disadvantages of Inheritance
    22. 11.22 More Programs
    23. Summary
    24. Exercises
  19. Chapter 12: Arrays
    1. 12.1 Introduction
    2. 12.2 One-dimensional Array Declaration and Initialization
    3. 12.3 Characteristics of Arrays
    4. 12.4 Accessing Array Elements Through Pointers
    5. 12.5 Arrays of Pointers
    6. 12.6 Passing Array Elements to a Function
    7. 12.7 Passing Complete Array Elements to a Function
    8. 12.8 Initialization of Arrays Using Functions
    9. 12.9 Two-dimensional Arrays
    10. 12.10 Pointers and Two-dimensional Arrays
    11. 12.11 Three- or Multi-dimensional Arrays
    12. 12.12 Arrays of Classes
    13. Summary
    14. Exercises
  20. Chapter 13: Pointers
    1. 13.1 Introduction
    2. 13.2 Features of Pointers
    3. 13.3 Pointer Declaration
    4. 13.4 Arithmetic Operations with Pointers
    5. 13.5 Pointer to Pointer
    6. 13.6 void Pointers
    7. 13.7 wild Pointers
    8. 13.8 Pointer to Class
    9. 13.9 Pointer to Object
    10. 13.10 The this Pointer
    11. 13.11 Pointer to Derived Classes and Base Class
    12. 13.12 Pointer to Members
    13. 13.13 Accessing Private Members with Pointers
    14. 13.14 Direct Access to Private Members
    15. 13.15 Addresses of Objects and void Pointers
    16. 13.16 More Programs
    17. Summary
    18. Exercises
  21. Chapter 14: C++ and Memory Models
    1. 14.1 Introduction
    2. 14.2 Memory Models
    3. 14.3 Dynamic Memory Allocation
    4. 14.4 The new and delete Operators
    5. 14.5 Heap Consumption
    6. 14.6 Overloading new and delete Operators
    7. 14.7 Overloading new and delete in Classes
    8. 14.8 Execution Sequence of Constructor and Destructor
    9. 14.9 Specifying Address of an Object
    10. 14.10 Dynamic Objects
    11. 14.11 Calling Convention
    12. Summary
    13. Exercises
  22. Chapter 15: Binding, Polymorphisms, and Virtual Functions
    1. 15.1 Introduction
    2. 15.2 Binding in C++
    3. 15.3 Pointer to Base and Derived Class Objects
    4. 15.4 Virtual Functions
    5. 15.5 Rules for Virtual Functions
    6. 15.6 Array of Pointers
    7. 15.7 Pure Virtual Functions
    8. 15.8 Abstract Classes
    9. 15.9 Working of Virtual Functions
    10. 15.10 Virtual Functions in Derived Classes
    11. 15.11 Object Slicing
    12. 15.12 Constructors and Virtual Functions
    13. 15.13 Virtual Destructors
    14. 15.14 Destructors and Virtual Functions
    15. Summary
    16. Exercises
  23. Chapter 16: Applications with Files
    1. 16.1 Introduction
    2. 16.2 File Stream Classes
    3. 16.3 Steps of File Operations
    4. 16.4 Checking for Errors
    5. 16.5 Finding End of a File
    6. 16.6 File Opening Modes
    7. 16.7 File Pointers and Manipulators
    8. 16.8 Manipulators with Arguments
    9. 16.9 Sequential Access Files
    10. 16.10 Binary and ASCII Files
    11. 16.11 Random Access Operation
    12. 16.12 Error Handling Functions
    13. 16.13 Command-Line Arguments
    14. 16.14 Strstreams
    15. 16.15 Sending Output to Devices
    16. 16.16 More Programs
    17. Summary
    18. Exercises
  24. Chapter 17: Generic Programming with Templates
    1. 17.1 Introduction
    2. 17.2 Need for Templates
    3. 17.3 Definition of Class Templates
    4. 17.4 Normal Function Templates
    5. 17.5 Working of Function Templates
    6. 17.6 Class Templates with More Parameters
    7. 17.7 Function Templates with More Arguments
    8. 17.8 Overloading of Template Functions
    9. 17.9 Member Function Templates
    10. 17.10 Recursion with Template Functions
    11. 17.11 Class Templates with Overloaded Operators
    12. 17.12 Class Templates Revisited
    13. 17.13 Class Templates and Inheritance
    14. 17.14 Bubble Sort Using Function Templates
    15. 17.15 Guidelines for Templates
    16. 17.16 Differences Between Templates and Macros
    17. 17.17 Linked Lists with Templates
    18. 17.18 More Programs
    19. Summary
    20. Exercises
  25. Chapter 18: Working with Strings
    1. 18.1 Introduction
    2. 18.2 Moving From C String to C++ String
    3. 18.3 Declaring and Initializing String Objects
    4. 18.4 Relational Operators
    5. 18.5 Handling String Objects
    6. 18.6 String Attributes
    7. 18.7 Accessing Elements of Strings
    8. 18.8 Comparing and Exchanging
    9. 18.9 Miscellaneous Functions
    10. 18.10 More Programs
    11. Summary
    12. Exercises
  26. Chapter 19: Exception Handling
    1. 19.1 Introduction
    2. 19.2 Principles of Exception Handling
    3. 19.3 The Keywords try, throw, and catch
    4. 19.4 Guidelines for Exception Handling
    5. 19.5 Multiple catch Statements
    6. 19.6 Catching Multiple Exceptions
    7. 19.7 Re-throwing Exception
    8. 19.8 Specifying Exceptions
    9. 19.9 Exceptions in Constructors and Destructors
    10. 19.10 Controlling Uncaught Exceptions
    11. 19.11 Exceptions and Operator Overloading
    12. 19.12 Exceptions and Inheritance
    13. 19.13 Class Templates with Exception Handling
    14. 19.14 Guidelines for Exception Handling
    15. 19.15 More Programs
    16. Summary
    17. Exercises
  27. Chapter 20: Overview of Standard Template Library
    1. 20.1 Introduction to STL
    2. 20.2 STL Programing Model
    3. 20.3 Containers
    4. 20.4 Sequence Containers
    5. 20.5 Associative Containers
    6. 20.6 Algorithms
    7. 20.7 Iterators
    8. 20.8 Vectors
    9. 20.9 Lists
    10. 20.10 Maps
    11. 20.11 Function Objects
    12. Summary
    13. Exercises
  28. Chapter 21: Additional Information about ANSI and TURBO-C++
    1. 21.1 Introduction
    2. 21.2 Innovative Data Types
    3. 21.3 New Type-casting Operators
    4. 21.4 The Keyword explicit
    5. 21.5 The Keyword mutable
    6. 21.6 Namespace Scope
    7. 21.7 Nested Namespaces
    8. 21.8 Anonymous Namespaces
    9. 21.9 The Keyword using
    10. 21.10 Namespace Alias
    11. 21.11 The Standard Namespace std
    12. 21.12 ANSI and Turbo-C++ Keywords
    13. 21.13 ANSI and Turbo-C++ Header Files
    14. 21.14 C++ Operator Keywords
    15. Summary
    16. Exercises
  29. Chapter 22: C++ Graphics
    1. 22.1 Introduction
    2. 22.2 Computer Display Modes
    3. 22.3 Video Display and Display Adapters
    4. 22.4 Initilisation of Graphics
    5. 22.5 Few Additional Graphics Functions
    6. 22.6 Programs Using Library Functions
    7. 22.7 Working with Texts
    8. 22.8 Filling Patterns with Different Colors and Styles
    9. 22.9 Mouse Programming
    10. 22.10 Drawing Noncommon Figures
    11. Summary
    12. Exercises
  30. Appendices
  31. Acknowledgements
  32. Copyright
  33. Back Cover

Product information

  • Title: Programming in C++, 2nd Edition
  • Author(s):
  • Release date: June 2013
  • Publisher(s): Pearson India
  • ISBN: 9789332520295