Contents

1. INTRODUCTION TO C++

1.1 Evolution of C++

1.2 ANSI Standard

1.3 Object-Oriented Technology

1.4 Disadvantage of Conventional Programming

1.5 Programming Paradigms

1.6 Preface to Object-Oriented Programming

1.7 Key Concepts of Object-Oriented Programming

1.8 Advantages of OOP

1.9 Object-Oriented Languages

1.10 Usage of OOP

1.11 Usage of C++

  Summary

  Exercises

2. INPUT AND OUTPUT IN C++

2.1 Introduction

2.2 Streams in C++

2.3 Pre-Defined Streams

2.4 Buffering

2.5 Stream Classes

2.6 Formatted and Unformatted Data

2.7 Unformatted Console I/O Operations

2.8 Typecasting with cout Statement

2.9 Member Functions of Istream Class

2.10 Formatted Console I/O Operations

2.11 Bit Fields

2.12 Flags Without Bit Field

2.13 Manipulators

2.14 User-Defined Manipulators

2.15 Manipulator with One Parameter

2.16 Manipulators with Multiple Parameters

2.17 Custom Built I/O Objects

  Summary

  Exercises

3. C++ DECLARATIONS

3.1 Introduction

3.2 Parts of C++ Program

3.3 Types of Tokens

3.4 Keywords

3.5 Identifiers

3.6 Dynamic Initialization

3.7 Data Types in C++

3.8 Basic Data Type

3.9 Derived Data Type

3.10 User-Defined Data Type

3.11 The void Data Type

3.12 Type Modifiers

3.13 Wrapping Around

3.14 Typecasting

3.15 Constants

3.16 Constant Pointers

3.17 Operators in C and C++

3.18 Precedence of Operators in C++

3.19 Referencing (&) and Dereferencing (*) Operators

3.20 Scope Access Operator

3.21 Memory Management Operators

3.22 Comma Operator

3.23 Comma in Place of Curly Braces

  Summary

  Exercises

4. CONTROL STRUCTURES

4.1 Introduction

4.2 Decision-Making Statements

4.3 The if–else Statement

4.4 The Nested if–else Statement

4.5 The jump Statement

4.6 The goto Statement

4.7 The break Statement

4.8 The continue Statement

4.9 The switch case Statement

4.10 The Nested switch( )case Statement

4.11 Loops in C/C++

4.12 The for Loop

4.13 Nested for Loops

4.14 The while Loop

4.15 The do-while Loop

  Summary

  Exercises

5. FUNCTIONS IN C++

5.1 Introduction

5.2 The main( ) Function in C and C++

5.3 Parts of Function

5.4 Passing Arguments

5.5 LValues and RValues

5.6 Return by Reference

5.7 Returning More Values by Reference

5.8 Default Arguments

5.9 The const Argument

5.10 Inputting Default Arguments

5.11 Inline Functions

5.12 Function Overloading

5.13 Principles of Function Overloading

5.14 Precautions with Function Overloading

5.15 Library Functions

  Summary

  Exercises

6. CLASSES AND OBJECTS

6.1 Introduction

6.2 Structures in C

6.3 Structures in C++

6.4 Classes in C++

6.5 Declaring Objects

6.6 The public Keyword

6.7 The private Keyword

6.8 The protected Keyword

6.9 Defining Member Functions

6.10 Characteristics of Member Functions

6.11 Outside Member Function Inline

6.12 Rules for Inline Functions

6.13 Data Hiding or Encapsulation

6.14 Classes, Objects and Memory

6.15 Static Member Variables and Functions

6.16 Static Object

6.17 Array of Objects

6.18 Objects as Function Arguments

6.19 friend Functions

6.20 The const Member Function

6.21 Recursive Member Function

6.22 Local Classes

6.23 Empty, Static and Const Classes

6.24 Member Functions and Non-Member Functions

6.25 The main( ) as a Member Function

6.26 Overloading Member Functions

6.27 Overloading main( ) Function

6.28 The main( ), Member Function and Indirect Recursion

6.29 Bit Fields and Classes

  Summary

  Exercises

7. CONSTRUCTORS AND DESTRUCTORS

7.1 Introduction

7.2 Constructors and Destructors

7.3 Characteristics of Constructors and Destructors

7.4 Applications with Constructors

7.5 Constructors with Arguments

7.6 Overloading Constructors

7.7 Constructors with Default Arguments

7.8 Copy Constructors

7.9 The const Objects

7.10 Destructors

7.11 Calling Constructors and Destructors

7.12 Qualifier and Nested Classes

7.13 Anonymous Objects

7.14 Private Constructors and Destructors

7.15 Dynamic Initialization Using Constructors

7.16 Dynamic Operators and Constructors

7.17 The main( ) as a Constructor and Destructor

7.18 Recursive Constructor

7.19 Program Execution before main( )

7.20 Constructor and Destructor with Static Members

7.21 Local vs Global Object

  Summary

  Exercises

8. OPERATOR OVERLOADING AND TYPE CONVERSION

8.1 Introduction

8.2 The Keyword Operator

8.3 Overloading Unary Operators

8.4 Operator Return Type

8.5 Constraint on Increment and Decrement Operators

8.6 Overloading Binary Operators

8.7 Overloading with friend Function

8.8 Type Conversion

8.9 Rules for Overloading Operators

8.10 One Argument Constructor and Operator Function

8.11 Overloading Stream Operators

  Summary

  Exercises

9. INHERITANCE

9.1 Introduction

9.2 Access Specifiers and Simple Inheritance

9.3 Protected Data with Private Inheritance

9.4 Types of Inheritances

9.5 Single Inheritance

9.6 Multilevel Inheritance

9.7 Multiple Inheritance

9.8 Hierarchical Inheritance

9.9 Hybrid Inheritance

9.10 Multipath Inheritance

9.11 Virtual Base Classes

9.12 Constructors, Destructors and Inheritance

9.13 Object as a Class Member

9.14 Abstract Classes

9.15 Qualifier Classes and Inheritance

9.16 Common Constructor

9.17 Pointers and Inheritance

9.18 Overloading Member Function

9.19 Advantages of Inheritance

9.20 Disadvantages of Inheritance

  Summary

  Exercises

10. POINTERS AND ARRAYS

10.1 Introduction

10.2 Pointer Declaration

10.3 Void Pointers

10.4 Wild Pointers

10.5 Pointer to Class

10.6 Pointer to Object

10.7 The this Pointer

10.8 Pointer to Derived Classes and Base Classes

10.9 Pointer to Members

10.10 Accessing Private Members with Pointers

10.11 Direct Access to Private Members

10.12 Address of Object and Void Pointers

10.13 Arrays

10.14 Characteristics of Arrays

10.15 Initialization of Arrays Using Functions

10.16 Arrays of Classes

   Summary

   Exercises

11. C++ AND MEMORY

11.1 Introduction

11.2 Memory Models

11.3 The new and delete Operators

11.4 Heap Consumption

11.5 Overloading new and delete Operators

11.6 Execution Sequence of Constructors and Destructors

11.7 Specifying Address of an Object

11.8 Dynamic Objects

11.9 Calling Convention

  Summary

  Exercises

12. BINDING, POLYMORPHISM AND VIRTUAL FUNCTIONS

12.1 Introduction

12.2 Binding in C++

12.3 Pointer to Derived Class Objects

12.4 Virtual Functions

12.5 Rules for Virtual Functions

12.6 Array of Pointers

12.7 Pure Virtual Functions

12.8 Abstract Classes

12.9 Working of Virtual Functions

12.10 Virtual Functions in Derived Classes

12.11 Object Slicing

12.12 Constructors and Virtual Functions

12.13 Virtual Destructors

12.14 Destructors and Virtual Functions

   Summary

   Exercises

13. APPLICATIONS WITH FILES

13.1 Introduction

13.2 File Stream Classes

13.3 Steps of File Operations

13.4 Checking for Errors

13.5 Finding End of a File

13.6 File Opening Modes

13.7 File Pointers and Manipulators

13.8 Manipulators with Arguments

13.9 Sequential Read and Write Operations

13.10 Binary and ASCII Files

13.11 Random Access Operation

13.12 Error Handling Functions

13.13 Command Line Arguments

13.14 Strstreams

13.15 Sending Output to Devices

   Summary

   Exercises

14. GENERIC PROGRAMMING WITH TEMPLATES

14.1 Introduction

14.2 Need of Template

14.3 Definition of Class Template

14.4 Normal Function Template

14.5 Working of Function Templates

14.6 Class Template with More Parameters

14.7 Function Templates with More Arguments

14.8 Overloading of Template Functions

14.9 Member Function Templates

14.10 Recursion with Template Function

14.11 Class Template with Overloaded Operators

14.12 Class Template Revisited

14.13 Class Templates and Inheritance

14.14 Bubble Sort Using Function Template

14.15 Guidelines for Templates

14.16 Difference Between Templates and Macros

14.17 Linked List with Templates

   Summary

   Exercises

15. EXCEPTION HANDLING

15.1 Introduction

15.2 Principles of Exception Handling

15.3 The Keywords try, throw and catch

15.4 Exception Handling Mechanism

15.5 Multiple Catch Statements

15.6 Catching Multiple Exceptions

15.7 Rethrowing Exception

15.8 Specifying Exception

15.9 Exceptions in Constructors and Destructors

15.10 Controlling Uncaught Exceptions

15.11 Exception and Operator Overloading

15.12 Exception and Inheritance

15.13 Class Template with Exception Handling

15.14 Guidelines for Exception Handling

   Summary

   Exercises

16. WORKING WITH STRINGS

16.1 Introduction

16.2 Moving from C String to C++ String

16.3 Declaring and Initializing String Objects

16.4 Relational Operators

16.5 Handling String Objects

16.6 String Attributes

16.7 Accessing Elements of Strings

16.8 Comparing and Exchanging

16.9 Miscellaneous Functions

  Summary

  Exercises

17. OVERVIEW OF STANDARD TEMPLATE LIBRARY (STL)

17.1 Introduction to STL

17.2 STL Programming Model

17.3 Containers

17.4 Sequence Containers

17.5 Associative Containers

17.6 Algorithms

17.7 Iterators

17.8 Vector

17.9 List

17.10 Maps

17.11 Function Objects

   Summary

   Exercises

18. ADDITIONAL ABOUT ANSI AND TURBO C++

18.1 Introduction

18.2 Innovative Data Types

18.3 New Typecasting Operators

18.4 The Keyword explicit

18.5 The Keyword mutable

18.6 Namespace Scope

18.7 Nested Namespaces

18.8 Anonymous Namespaces

18.9 The using Keyword

18.10 Namespace Alias

18.11 The Standard Namespace STD

18.12 ANSI and TURBO C++ Keywords

18.13 ANSI and TURBO C++ Header Files

18.14 C++ Operator Keywords

   Summary

   Exercises

19. MARCHING TOWARDS JAVA

19.1 Evolution of Java

19.2 Java Technology

19.3 Features of Java

19.4 Overview of Java

19.5 Differences between C/C++ and Java

19.6 Keywords

19.7 Java Virtual Machine (JVM)

19.8 Structure of a Java Program

19.9 Implementing a Java Program

19.10 Constants, Variables and Data Types

19.11 Classes, Objects and Methods

19.12 Overriding Methods

19.13 Multithreading

19.14 Life Cycle of Thread

19.15 Packages

19.16 Applets

   Summary

   Exercises

Appendices

Index

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

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