You are previewing Object-Oriented Programming with ANSI and Turbo C++.
O'Reilly logo
Object-Oriented Programming with ANSI and Turbo C++

Book Description

A student-friendly, practical and example-driven book, Object-Oriented Programming with ANSI and Turbo C++ gives you a solid background in the fundamentals of C++ which has emerged as a standard object-oriented programming language. This comprehensive book, enriched with illustrations and a number of solved programs, will help you unleash the full potential of C++. Prof. Kamthane explains each concept in an easy-to-understand manner and takes you straight to applications. He believes that practice makes a man perfect, and this book aims at making you one.

Table of Contents

  1. Cover Page
  2. Title Page
  3. Dedication Page
  4. Copyright Page
  5. Preface
  6. Acknowledgements
  7. Contents
  8. 1. Introduction to C++
    1. 1.1- Evolution of C++
    2. 1.2- ANSI Standard
    3. 1.3- Object-Oriented Technology
    4. 1.4- Disadvantage of Conventional Programming
    5. 1.5- Programming Paradigms
    6. 1.6- Preface to Object-Oriented Programming
    7. 1.7- Key Concepts of Object-Oriented Programming
    8. 1.8- Advantages of OOP
    9. 1.9- Object-Oriented Languages
    10. 1.10- Usage of OOP
    11. 1.11- Usage of C++
    12. Summary
    13. Exercises
  9. 2. Input and Output In C++
    1. 2.1- Introduction
    2. 2.2- Streams in C++
    3. 2.3- Pre-Defined Streams
    4. 2.4- Buffering
    5. 2.5- Stream Classes
    6. 2.6- Formatted and Unformatted Data
    7. 2.7- Unformatted Console I/O Operations
    8. 2.8- Typecasting with Cout Statement
    9. 2.9- Member Functions of Istream Class
    10. 2.10- Formatted Console I/O Operations
    11. 2.11- Bit Fields
    12. 2.12- Flags without Bit Field
    13. 2.13- Manipulators
    14. 2.14- User-Defined Manipulators
    15. 2.15- Manipulator with One Parameter
    16. 2.16- Manipulators with Multiple Parameters
    17. 2.17- Custom Built I/O Objects
    18. Summary
    19. Exercises
  10. 3. C++ Declarations
    1. 3.1- Introduction
    2. 3.2- Parts of C++ Program
    3. 3.3- Types of Tokens
    4. 3.4- Keywords
    5. 3.5- Identifiers
    6. 3.6- Dynamic Initialization
    7. 3.7- Data Types in C++
    8. 3.8- Basic Data Type
    9. 3.9- Derived Data Type
    10. 3.10- User-Defined Data Type
    11. 3.11- The Void Data Type
    12. 3.12- Type Modifiers
    13. 3.13- Wrapping Around
    14. 3.14- Typecasting
    15. 3.15- Constants
    16. 3.16- Constant Pointers
    17. 3.17- Operators in C and C++
    18. 3.18- Precedence of Operators in C++
    19. 3.19- Referencing (&) and Dereferencing (*) Operators
    20. 3.20- Scope Access Operator
    21. 3.21- Memory Management Operators
    22. 3.22- Comma Operator
    23. 3.23- Comma in Place of Curly Braces
    24. Summary
    25. Exercises
  11. 4. Control Structures
    1. 4.1- Introduction
    2. 4.2- Decision-Making Statements
    3. 4.3- The if–else Statement
    4. 4.4- The Nested if–else Statement
    5. 4.5- The jump Statement
    6. 4.6- The goto Statement
    7. 4.7- The Break Statement
    8. 4.8- The Continue Statement
    9. 4.9- The Switch Case Statement
    10. 4.10- The Nested Switch()Case Statement
    11. 4.11- Loops in C/C++
    12. 4.12- The for Loop
    13. 4.13- Nested for Loops
    14. 4.14- The while Loop
    15. 4.15- The do-while Loop
    16. Summary
    17. Exercises
  12. 5. Functions in C++
    1. 5.1- Introduction
    2. 5.2- The Main() Function in C and C++
    3. 5.3- Parts of Function
    4. 5.4- Passing Arguments
    5. 5.5- LValues and RValues
    6. 5.6- Return by Reference
    7. 5.7- Returning More Values by Reference
    8. 5.8- Default Arguments
    9. 5.9- The Const Argument
    10. 5.10- Inputting Default Arguments
    11. 5.11- Inline Functions
    12. 5.12- Function Overloading
    13. 5.13- Principles of Function Overloading
    14. 5.14- Precautions with Function Overloading
    15. 5.15- Library Functions
    16. Summary
    17. Exercises
  13. 6. Classes and Objects
    1. 6.1- Introduction
    2. 6.2- Structures in C
    3. 6.3- Structures in C++
    4. 6.4- Classes in C++
    5. 6.5- Declaring Objects
    6. 6.6- The public Keyword
    7. 6.7- The Private Keyword
    8. 6.8- The Protected Keyword
    9. 6.9- Defining Member Functions
    10. 6.10- Characteristics of Member Functions
    11. 6.11- Outside Member Function Inline
    12. 6.12- Rules for Inline Functions
    13. 6.13- Data Hiding or Encapsulation
    14. 6.14- Classes, Objects and Memory
    15. 6.15- Static Member Variables and Functions
    16. 6.16- Static Object
    17. 6.17- Array of Objects
    18. 6.18- Objects as Function Arguments
    19. 6.19- Friend Functions
    20. 6.20- The Const Member Function
    21. 6.21- Recursive Member Function
    22. 6.22- Local Classes
    23. 6.23- Empty, Static and Const Classes
    24. 6.24- Member Functions and Non-Member Functions
    25. 6.25- The Main() as a Member Function
    26. 6.26- Overloading Member Functions
    27. 6.27- Overloading Main() Function
    28. 6.28- The Main(), Member Function and Indirect Recursion
    29. 6.29- Bit Fields and Classes
    30. Summary
    31. Exercises
  14. 7. Constructors and Destructors
    1. 7.1- Introduction
    2. 7.2- Constructors and Destructors
    3. 7.3- Characteristics of Constructors and Destructors
    4. 7.4- Applications with Constructors
    5. 7.5- Constructors with Arguments
    6. 7.6- Overloading Constructors
    7. 7.7- Constructors with Default Arguments
    8. 7.8- Copy Constructors
    9. 7.9- The Const Objects
    10. 7.10- Destructors
    11. 7.11- Calling Constructors and Destructors
    12. 7.12- Qualifier and Nested Classes
    13. 7.13- Anonymous Objects
    14. 7.14- Private Constructors and Destructors
    15. 7.15- Dynamic Initialization Using Constructors
    16. 7.16- Dynamic Operators and Constructors
    17. 7.17- The Main() as a Constructor and Destructor
    18. 7.18- Recursive Constructor
    19. 7.19- Program ExecutiOn Before Main()
    20. 7.20- Constructor and Destructor with Static Members
    21. 7.21- Local vs Global Object
    22. Summary
    23. Exercises
  15. 8. Operator Overloading and Type Conversion
    1. 8.1- Introduction
    2. 8.2- The Keyword Operator
    3. 8.3- Overloading Unary Operators
    4. 8.4- Operator Return Type
    5. 8.5- Constraint on Increment and Decrement Operators
    6. 8.6- Overloading Binary Operators
    7. 8.7- Overloading with Friend Function
    8. 8.8- Type Conversion
    9. 8.9- Rules for Overloading Operators
    10. 8.10- One Argument Constructor and Operator Function
    11. 8.11- Overloading Stream Operators
    12. Summary
    13. Exercises
  16. 9. Inheritance
    1. 9.1- Introduction
    2. 9.2- Access Specifiers and Simple Inheritance
    3. 9.3- Protected Data with Private Inheritance
    4. 9.4- Types of Inheritances
    5. 9.5- Single Inheritance
    6. 9.6- Multilevel Inheritance
    7. 9.7- Multiple Inheritance
    8. 9.8- Hierarchical Inheritance
    9. 9.9- Hybrid Inheritance
    10. 9.10- Multipath Inheritance
    11. 9.11- Virtual Base Classes
    12. 9.12- Constructors, Destructors and Inheritance
    13. 9.13- Object as a Class Member
    14. 9.14- Abstract Classes
    15. 9.15- Qualifier Classes and Inheritance
    16. 9.16- Common Constructor
    17. 9.17- Pointers and Inheritance
    18. 9.18- Overloading Member Function
    19. 9.19- Advantages of Inheritance
    20. 9.20- Disadvantages of Inheritance
    21. Summary
    22. Exercises
  17. 10. Pointers and Arrays
    1. 10.1- Introduction
    2. 10.2- Pointer Declaration
    3. 10.3- Void Pointers
    4. 10.4- Wild Pointers
    5. 10.5- Pointer to Class
    6. 10.6- Pointer to Object
    7. 10.7- The this Pointer
    8. 10.8- Pointer to Derived Classes and Base Classes
    9. 10.9- Pointer to Members
    10. 10.10- Accessing Private Members with Pointers
    11. 10.11- Direct Access to Private Members
    12. 10.12- Address of Object and Void Pointers
    13. 10.13- Arrays
    14. 10.14- Characteristics of Arrays
    15. 10.15- Initialization of Arrays Using Functions
    16. 10.16- Arrays of Classes
    17. Summary
    18. Exercises
  18. 11. C++ and Memory
    1. 11.1- Introduction
    2. 11.2- Memory Models
    3. 11.3- The New and Delete Operators
    4. 11.4- Heap Consumption
    5. 11.5- Overloading New and Delete Operators
    6. 11.6- Execution Sequence of Constructors and Destructors
    7. 11.7- Specifying Address of an Object
    8. 11.8- Dynamic Objects
    9. 11.9- Calling Convention
    10. Summary
    11. Exercises
  19. 12. Binding, Polymorphism and Virtual Functions
    1. 12.1- Introduction
    2. 12.2- Binding in C++
    3. 12.3- Pointer to Derived Class Objects
    4. 12.4- Virtual Functions
    5. 12.5- Rules for Virtual Functions
    6. 12.6- Array of Pointers
    7. 12.7- Pure Virtual Functions
    8. 12.8- Abstract Classes
    9. 12.9- Working of Virtual Functions
    10. 12.10- Virtual Functions in Derived Classes
    11. 12.11- Object Slicing
    12. 12.12- Constructors and Virtual Functions
    13. 12.13- Virtual Destructors
    14. 12.14- Destructors and Virtual Functions
    15. Summary
    16. Exercises
  20. 13. Applications with Files
    1. 13.1- Introduction
    2. 13.2- File Stream Classes
    3. 13.3- Steps of File Operations
    4. 13.4- Checking for Errors
    5. 13.5- Finding End of a File
    6. 13.6- File Opening Modes
    7. 13.7- File Pointers and Manipulators
    8. 13.8- Manipulators with Arguments
    9. 13.9- Sequential Read and Write Operations
    10. 13.10- Binary and ASCII Files
    11. 13.11- Random Access Operation
    12. 13.12- Error Handling Functions
    13. 13.13- Command Line Arguments
    14. 13.14- Strstreams
    15. 13.15- Sending Output to Devices
    16. Summary
    17. Exercises
  21. 14. Generic Programming with Templates
    1. 14.1- Introduction
    2. 14.2- Need of Template
    3. 14.3- Definition of Class Template
    4. 14.4- Normal Function Template
    5. 14.5- Working of Function Templates
    6. 14.6- Class Template with More Parameters
    7. 14.7- Function Templates with More Arguments
    8. 14.8- Overloading of Template Functions
    9. 14.9- Member Function Templates
    10. 14.10- Recursion with Template Function
    11. 14.11- Class Template with Overloaded Operators
    12. 14.12- Class Template Revisited
    13. 14.13- Class Templates and Inheritance
    14. 14.14- Bubble Sort Using Function Template
    15. 14.15- Guidelines for Templates
    16. 14.16- Difference Between Templates and Macros
    17. 14.17- Linked List with Templates
    18. Summary
    19. Exercises
  22. 15. Exception Handling
    1. 15.1- Introduction
    2. 15.2- Principles of Exception Handling
    3. 15.3- The Keywords Try, Throw and Catch
    4. 15.4- Exception Handling Mechanism
    5. 15.5- Multiple Catch Statements
    6. 15.6- Catching Multiple Exceptions
    7. 15.7- Rethrowing Exception
    8. 15.8- Specifying Exception
    9. 15.9- Exceptions in Constructors and Destructors
    10. 15.10- Controlling Uncaught Exceptions
    11. 15.11- Exception and Operator Overloading
    12. 15.12- Exception and Inheritance
    13. 15.13- Class Template with Exception Handling
    14. 15.14- Guidelines for Exception Handling
    15. Summary
    16. Exercises
  23. 16. Working with Strings
    1. 16.1- Introduction
    2. 16.2- Moving from C String to C++ String
    3. 16.3- Declaring and Initializing String Objects
    4. 16.4- Relational Operators
    5. 16.5- Handling String Objects
    6. 16.6- String Attributes
    7. 16.7- Accessing Elements of Strings
    8. 16.8- Comparing and Exchanging
    9. 16.9- Miscellaneous Functions
    10. Summary
    11. Exercises
  24. 17. Overview of Standard Template Library (STL)
    1. 17.1- Introduction to STL
    2. 17.2- STL Programming Model
    3. 17.3- Containers
    4. 17.4- Sequence Containers
    5. 17.5- Associative Containers
    6. 17.6- Algorithms
    7. 17.7- Iterators
    8. 17.8- Vector
    9. 17.9- List
    10. 17.10- Maps
    11. 17.11- Function Objects
    12. Summary
    13. Exercises
  25. 18. Additional about Ansi and Turbo C++
    1. 18.1- Introduction
    2. 18.2- Innovative Data Types
    3. 18.3- New Typecasting Operators
    4. 18.4- The Keyword explicit
    5. 18.5- The Keyword mutable
    6. 18.6- Namespace Scope
    7. 18.7- Nested Namespaces
    8. 18.8- Anonymous Namespaces
    9. 18.9- The Using Keyword
    10. 18.10- Namespace Alias
    11. 18.11- The Standard Namespace STD
    12. 18.12- ANSI and TURBO C++ Keywords
    13. 18.13- ANSI and TURBO C++ Header Files
    14. 18.14- C++ Operator Keywords
    15. Summary
    16. Exercises
  26. 19. Marching Towards Java
    1. 19.1- Evolution of Java
    2. 19.2- Java Technology
    3. 19.3- Features of Java
    4. 19.4- Overview of Java
    5. 19.5- Differences between C/C++ and Java
    6. 19.6- Keywords
    7. 19.7- Java Virtual Machine (JVM)
    8. 19.8- Structure of a Java Program
    9. 19.9- Implementing a Java Program
    10. 19.10- Constants, Variables and Data Types
    11. 19.11- Classes, Objects and Methods
    12. 19.12- Overriding Methods
    13. 19.13- Multithreading
    14. 19.14- Life Cycle of Thread
    15. 19.15- Packages
    16. 19.16- Applets
    17. Summary
    18. Exercises
  27. Appendices
  28. Index
  29. Back Cover