Contents

Preface

About the Author

1.  Introduction to C++

1.1  Differences between C and C++

1.2  Evolution of C++

1.3  The ANSI Standard

1.4  The Object Oriented Technology

1.5  Disadvantage of Conventional Programming

1.6  Programming Paradigms

1.7  Preface to Object Oriented Programming

1.8  Key Concepts of Object Oriented Programming

1.9  Advantages of OOP

1.10  Object Oriented Languages

1.11  Usage of OOP

1.12  Usage of C++

Summary

Exercises

2.  Basics of C++

2.1  Introduction

2.2  Steps to Create and Execute a C++ Program

2.3  Flowchart for Creating a Source File, Compiling, Linking and Executing in C++

2.4  C++ Environments

2.5  Typical C++ Environment (Borland C++)

2.6  Structure of a C++ Program

2.7  Illustrative Simple Program in C++ without Class

2.8  Header Files and Libraries

Summary

Exercises

3.  Input and Output in C++

3.1  Introduction

3.2  Streams in C++ and Stream Classes

3.3  Pre-defined Streams

3.4  Buffering

3.5  Stream Classes

3.6  Formatted and Unformatted Data

3.7  Unformatted Console I/O Operations

3.8  Type Casting with the cout Statement

3.9  Member Functions of the istream Class

3.10  Formatted Console I/O Operations

3.11  Bit Fields

3.12  Flags without Bit Fields

3.13  Manipulators

3.14  User-defined Manipulators

3.15  Manipulator with One Parameter

3.16  Manipulators with Multiple Parameters

3.17  More Programs

Summary

Exercises

4.  C++ Declarations

4.1  Introduction

4.2  Tokens

4.3  Variable Declaration and Initialization

4.4  Data Types in C++

4.5  Operators in C and C++

4.6  Scope Access Operator

4.7  Namespace

4.8  Memory Management Operators

4.9  Comments

4.10  Comma Operator

4.11  Comma in Place of Curly Braces

4.12  More Programs

Summary

Exercises

5.  Decision Statements

5.1  Introduction

5.2  The if Statement

5.3  Multiple ifs

5.4  The if-else Statement

5.5  Nested if-else Statements

5.6  The else-if Ladder

5.7  Unconditional Control Transfer Statements

5.8  The switch Statement

5.9  Nested switch case

Summary

Exercises

6.  Control Loop Structures

6.1  Introduction

6.2  What Is a Loop?

6.3  The for Loop

6.4  Nested for Loops

6.5  The while Loop

6.6  The do-while Loop

6.7  The do-while Statement with while Loop

6.8  More Programs

Summary

Exercises

7.  Functions in C++

7.1  Introduction

7.2  Parts of a Function

7.3  Passing Arguments

7.4  Lvalues and Rvalues

7.5  Return by Reference

7.6  Returning More Values by Reference

7.7  Default Arguments

7.8  const Arguments

7.9  Inputting Default Arguments

7.10  Inline Functions

7.11  Function Overloading

7.12  Principles of Function Overloading

7.13  Precautions with Function Overloading

7.14  Recursion

7.15  Library Functions

7.16  More Programs

Summary

Exercises

8.  Classes and Objects

8.1  Introduction

8.2  Structure in C

8.3  Structure in C++

8.4  Classes in C++

8.5  Declaring Objects

8.6  The public Keyword

8.7  The private Keyword

8.8  The protected Keyword

8.9  Access Specifiers and Their Scope

8.10  Defining Member Functions

8.11  Characteristics of Member Functions

8.12  Outside Member Function as Inline

8.13  Rules for Inline Functions

8.14  Data Hiding or Encapsulation

8.15  Classes, Objects, and Memory

8.16  static Member Variables

8.17  static Member Functions

8.18  static Object

8.19  Array of Objects

8.20  Objects as Function Arguments

8.21  friend Functions

8.22  The const Member Functions

8.23  The Volatile Member Function

8.24  Recursive Member Function

8.25  Local Classes

8.26  empty, static, and const Classes

8.27  Member Function and Non-member Function

8.28  The main() Function as a Member Function

8.29  Overloading Member Functions

8.30  Overloading main() Functions

8.31  The main(), Member Function, and Indirect Recursion

8.32  Bit Fields and Classes

8.33  Nested Class

8.34  More Programs

Summary

Exercises

9.  Constructors and Destructors

9.1  Introduction

9.2  Constructors and Destructors

9.3  Characteristics of Constructors and Destructors

9.4  Applications with Constructors

9.5  Constructors with Arguments (Parameterized Constructor)

9.6  Overloading Constructors (Multiple Constructors)

9.7  Array of Objects Using Constructors

9.8  Constructors with Default Arguments

9.9  Copy Constructors

9.10  The const Objects

9.11  Destructors

9.12  Calling Constructors and Destructors

9.13  Qualifier and Nested Classes

9.14  Anonymous Objects

9.15  Private Constructors and Destructors

9.16  Dynamic Initialization Using Constructors

9.17  Dynamic Operators and Constructors

9.18  main() as a Constructor and Destructor

9.19  Recursive Constructors

9.20  Program Execution Before main()

9.21  Constructor and Destructor with Static Members

9.22  Local Versus Global Object

9.23   More Programs

Summary

Exercises

10.  Operator Overloading and Type Conversion

10.1  Introduction

10.2  The Keyword Operator

10.3  Overloading Unary Operators

10.4  Operator Return Type

10.5  Constraint on Increment and Decrement Operators

10.6  Overloading Binary Operators

10.7  Overloading with friend Function

10.8  Overloading Assignment Operator (=)

10.9  Type Conversion

10.10  Rules for Overloading Operators

10.11  One-Argument Constructor and Operator Function

10.12  Overloading Stream Operators

10.13  More Programs

Summary

Exercises

11.  Inheritance

11.1  Introduction

11.2  Reusability

11.3  Access Specifiers and Simple Inheritance

11.4  Protected Data with Private Inheritance

11.5  Types of Inheritance

11.6  Single Inheritance

11.7  Multilevel Inheritance

11.8  Multiple Inheritance

11.9  Hierarchical Inheritance

11.10  Hybrid Inheritance

11.11  Multipath Inheritance

11.12  Virtual Base Classes

11.13  Constructors, Destructors, and Inheritance

11.14  Object as a Class Member

11.15  Abstract Classes

11.16  Qualifier Classes and Inheritance

11.17  Constructors in Derived Class

11.18  Pointers and Inheritance

11.19  Overloading Member Function

11.20  Advantages of Inheritance

11.21  Disadvantages of Inheritance

11.22  More Programs

Summary

Exercises

12.  Arrays

12.1  Introduction

12.2  One-dimensional Array Declaration and Initialization

12.3  Characteristics of Arrays

12.4  Accessing Array Elements Through Pointers

12.5  Arrays of Pointers

12.6  Passing Array Elements to a Function

12.7  Passing Complete Array Elements to a Function

12.8  Initialization of Arrays Using Functions

12.9  Two-dimensional Arrays

12.10  Pointers and Two-dimensional Arrays

12.11  Three- or Multi-dimensional Arrays

12.12  Arrays of Classes

Summary

Exercises

13.  Pointers

13.1  Introduction

13.2  Features of Pointers

13.3  Pointer Declaration

13.4  Arithmetic Operations with Pointers

13.5  Pointer to Pointer

13.6  void Pointers

13.7  wild Pointers

13.8  Pointer to Class

13.9  Pointer to Object

13.10  The this Pointer

13.11  Pointer to Derived Classes and Base Class

13.12  Pointer to Members

13.13  Accessing Private Members with Pointers

13.14  Direct Access to Private Members

13.15  Addresses of Objects and void Pointers

13.16  More Programs

Summary

Exercises

14.  C++ and Memory Models

14.1  Introduction

14.2  Memory Models

14.3  Dynamic Memory Allocation

14.4  The new and delete Operators

14.5  Heap Consumption

14.6  Overloading new and delete Operators

14.7  Overloading new and delete in Classes

14.8  Execution Sequence of Constructor and Destructor

14.9  Specifying Address of an Object

14.10  Dynamic Objects

14.11  Calling Convention

Summary

Exercises

15.  Binding, Polymorphisms, and Virtual Functions

15.1  Introduction

15.2  Binding in C++

15.3  Pointer to Base and Derived Class Objects

15.4  Virtual Functions

15.5  Rules for Virtual Functions

15.6  Array of Pointers

15.7  Pure Virtual Functions

15.8  Abstract Classes

15.9  Working of Virtual Functions

15.10  Virtual Functions in Derived Classes

15.11  Object Slicing

15.12  Constructors and Virtual Functions

15.13  Virtual Destructors

15.14  Destructors and Virtual Functions

Summary

Exercises

16.  Applications with Files

16.1  Introduction

16.2  File Stream Classes

16.3  Steps of File Operations

16.4  Checking for Errors

16.5  Finding End of a File

16.6  File Opening Modes

16.7  File Pointers and Manipulators

16.8  Manipulators with Arguments

16.9  Sequential Access Files

16.10  Binary and ASCII Files

16.11  Random Access Operation

16.12  Error Handling Functions

16.13  Command-Line Arguments

16.14  Strstreams

16.15  Sending Output to Devices

16.16  More Programs

Summary

Exercises

17.  Generic Programming with Templates

17.1  Introduction

17.2  Need for Templates

17.3  Definition of Class Templates

17.4  Normal Function Templates

17.5  Working of Function Templates

17.6  Class Templates with More Parameters

17.7  Function Templates with More Arguments

17.8  Overloading of Template Functions

17.9  Member Function Templates

17.10  Recursion with Template Functions

17.11  Class Templates with Overloaded Operators

17.12  Class Templates Revisited

17.13  Class Templates and Inheritance

17.14  Bubble Sort Using Function Templates

17.15  Guidelines for Templates

17.16  Differences Between Templates and Macros

17.17  Linked Lists with Templates

17.18  More Programs

Summary

Exercises

18.  Working with Strings

18.1  Introduction

18.2  Moving From C String to C++ String

18.3  Declaring and Initializing String Objects

18.4  Relational Operators

18.5  Handling String Objects

18.6  String Attributes

18.7  Accessing Elements of Strings

18.8  Comparing and Exchanging

18.9  Miscellaneous Functions

18.10  More Programs

Summary

Exercises

19.  Exception Handling

19.1  Introduction

19.2  Principles of Exception Handling

19.3  The Keywords try, throw, and catch

19.4  Guidelines for Exception Handling

19.5  Multiple catch Statements

19.6  Catching Multiple Exceptions

19.7  Re-throwing Exception

19.8  Specifying Exceptions

19.9  Exceptions in Constructors and Destructors

19.10  Controlling Uncaught Exceptions

19.11  Exceptions and Operator Overloading

19.12  Exceptions and Inheritance

19.13  Class Templates with Exception Handling

19.14  Guidelines for Exception Handling

19.15  More Programs

Summary

Exercises

20.  Overview of Standard Template Library

20.1  Introduction to STL

20.2  STL Programing Model

20.3  Containers

20.4  Sequence Containers

20.5  Associative Containers

20.6  Algorithms

20.7  Iterators

20.8  Vectors

20.9  Lists

20.10  Maps

20.11  Function Objects

Summary

Exercises

21.  Additional Information about ANSI and TURBO-C++

21.1  Introduction

21.2  Innovative Data Types

21.3  New Type-casting Operators

21.4  The Keyword explicit

21.5  The Keyword mutable

21.6  Namespace Scope

21.7  Nested Namespaces

21.8  Anonymous Namespaces

21.9  The Keyword using

21.10  Namespace Alias

21.11  The Standard Namespace std

21.12  ANSI and Turbo-C++ Keywords

21.13  ANSI and Turbo-C++ Header Files

21.14  C++ Operator Keywords

Summary

Exercises

22.  C++ Graphics

22.1  Introduction

22.2  Computer Display Modes

22.3  Video Display and Display Adapters

22.4  Initilisation of Graphics

22.5  Few Additional Graphics Functions

22.6  Programs Using Library Functions

22.7  Working with Texts

22.8  Filling Patterns with Different Colors and Styles

22.9  Mouse Programming

22.10  Drawing Noncommon Figures

Summary

Exercises

Appendices

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset