C++ Programming

Book description

This book begins by explaining key concepts in programming, and elaborates on characteristic of class, including inheritance, derivation and polymorphism. It also introduces generic programming and Standard Template Library, I/O Stream Library and Exception Handling. The concepts and methods are illustrated via examples step by step, making the book an essential reading for beginners to C++ programming.

Table of contents

  1. Cover
  2. Title Page
  3. Copyright
  4. Preface
  5. Contents
  6. 1 Introduction
    1. 1.1 The Development of Computer Programming Languages
      1. 1.1.1 Machine Language and Assembly Language
      2. 1.1.2 High-level Language
      3. 1.1.3 Object-oriented Language
    2. 1.2 Object-oriented Method
      1. 1.2.1 The Origin of Object-oriented Method
      2. 1.2.2 Basic Concepts of Object-oriented
    3. 1.3 Object-oriented Software Development
      1. 1.3.1 Analysis
      2. 1.3.2 Design
      3. 1.3.3 Programming
      4. 1.3.4 Test
      5. 1.3.5 Maintenance
    4. 1.4 Representation and Storage of Information
      1. 1.4.1 Digital System of Computers
      2. 1.4.2 Conversions among Numeral Systems
      3. 1.4.3 Storage Units of Information
      4. 1.4.4 Binary-coded Representation
      5. 1.4.5 Fixed Point Number and Floating-Point Number
      6. 1.4.6 The Number Range that can be Represented
      7. 1.4.7 Representation of Non-numerical Information
    5. 1.5 The Development Process of Programs
      1. 1.5.1 Elementary Terms
      2. 1.5.2 The Development Process
    6. 1.6 Summary
    7. Exercises
  7. 2 Elementary C++ Programming
    1. 2.1 An Overview of C++ Language
      1. 2.1.1 Origins of C++
      2. 2.1.2 Characteristics of C++
      3. 2.1.3 C++ Programming Examples
      4. 2.1.4 Character Set
      5. 2.1.5 Lexical Tokens
    2. 2.2 Basic Data Types and Expressions
      1. 2.2.1 Basic Data Types
      2. 2.2.2 Constants
      3. 2.2.3 Variables
      4. 2.2.4 Symbol Constants
      5. 2.2.5 Operators and Expressions
      6. 2.2.6 Statement
    3. 2.3 Data Input and Output
      1. 2.3.1 I/O Stream
      2. 2.3.2 Predefined Input and Output Operator
      3. 2.3.3 Simple I/O Format Control
    4. 2.4 The Fundamental Control Structures of Algorithms
      1. 2.4.1 Achieving Case Structure Using if Statement
      2. 2.4.2 Multiple Selection Structure
      3. 2.4.3 Loop Structure
      4. 2.4.4 Nestings of Loop Structure and Case Structure
      5. 2.4.5 Other Control Statements
    5. 2.5 User-Defined Data Type
      1. 2.5.1 typedef Declaration
      2. 2.5.2 Enumeration Type – enum
      3. 2.5.3 Structure
      4. 2.5.4 Union
    6. 2.6 Summary
    7. Exercises
  8. 3 Functions
    1. 3.1 Definition and Use of Function
      1. 3.1.1 Definition of Function
      2. 3.1.2 Function Calls
      3. 3.1.3 Passing Parameters Between Functions
    2. 3.2 Inline Functions
    3. 3.3 Default Formal Parameters in Functions
    4. 3.4 Function Overloading
    5. 3.5 Using C++ System Functions
    6. 3.6 Summary
    7. Exercises
  9. 4 Class and Object
    1. 4.1 Basic Features of Object-Oriented Design
      1. 4.1.1 Abstraction
      2. 4.1.2 Encapsulation
      3. 4.1.3 Inheritance
      4. 4.1.4 Polymorphism
    2. 4.2 Class and Object
      1. 4.2.1 Definition of Class
      2. 4.2.2 Access Control to Class Members
      3. 4.2.3 Member Function of Class
      4. 4.2.4 Object
      5. 4.2.5 Program Instance
    3. 4.3 Constructor and Destructor
      1. 4.3.1 Class Constructors
      2. 4.3.2 The Copy Constructor
      3. 4.3.3 Class Destructor
      4. 4.3.4 Program Instance
    4. 4.4 Combination of Classes
      1. 4.4.1 Combination
      2. 4.4.2 Forward Declaration
    5. 4.5 UML
      1. 4.5.1 Brief Introduction of UML
      2. 4.5.2 UML Class Diagrams
    6. 4.6 Program Instance – Personnel Information Management Program
      1. 4.6.1 Design of Class
      2. 4.6.2 Source Code and Description
      3. 4.6.3 Running Result and Analyses
    7. 4.7 Summary
    8. Exercises
  10. 5 Data Sharing and Protecting
    1. 5.1 Scope and Visibility of Identifiers
      1. 5.1.1 Scope
      2. 5.1.2 Visibility
    2. 5.2 Lifetime of Object
      1. 5.2.1 Static Lifetime
      2. 5.2.2 Dynamic Lifetime
    3. 5.3 Static Members of Class
      1. 5.3.1 Static Data Member
      2. 5.3.2 Static Function Member
    4. 5.4 Friend of Class
      1. 5.4.1 Friend Function
      2. 5.4.2 Friend Class
    5. 5.5 Protection of Shared Data
      1. 5.5.1 Constant Reference
      2. 5.5.2 Constant Object
      3. 5.5.3 Class Members Modified by const
    6. 5.6 Multifile Structure and Compilation Preprocessing Directives
      1. 5.6.1 General Organization Structure of C++ Program
      2. 5.6.2 External Variable and External Function
      3. 5.6.3 Standard C++ Library and Namespace
      4. 5.6.4 Compilation Preprocessing
    7. 5.7 Example – Personnel Information Management Program
    8. 5.8 Summary
    9. Exercises
  11. 6 Arrays, Pointers, and Strings
    1. 6.1 Arrays
      1. 6.1.1 Declaration and Use of Arrays
      2. 6.1.2 Storage and Initialization of Arrays
      3. 6.1.3 Using Arrays as Function Parameters
      4. 6.1.4 Object Arrays
      5. 6.1.5 Program Examples
    2. 6.2 Pointers
      1. 6.2.1 Access Method of Memory Space
      2. 6.2.2 Declaration of Pointer Variables
      3. 6.2.3 Operations Related to Addresses – ‘*’ and ‘&’
      4. 6.2.4 Assignment of Pointers
      5. 6.2.5 Pointer Operations
      6. 6.2.6 Using Pointers to Process Array Elements
      7. 6.2.7 Pointer Arrays
      8. 6.2.8 Using Pointers as Function Parameters
      9. 6.2.9 Pointer-Type Functions
      10. 6.2.10 Pointers that Point to Functions
      11. 6.2.11 Object Pointers
    3. 6.3 Dynamic Memory Allocation
      1. 6.3.1 new Operation and delete Operation
      2. 6.3.2 Dynamic Memory Allocation and Release Functions
    4. 6.4 Deep Copy and Shallow Copy
    5. 6.5 Strings
      1. 6.5.1 Using Character Arrays to Store and Process Strings
      2. 6.5.2 The string Class
    6. 6.6 Program Example – Personnel Information Management Program
    7. 6.7 Summary
    8. Exercises
  12. 7 Inheritance and Derivation
    1. 7.1 Inheritance and Derivation of Class
      1. 7.1.1 Instances of Inheritance and Derivation
      2. 7.1.2 Definition of Derived Class
      3. 7.1.3 The Generation Process of Derived Classes
    2. 7.2 Access Control
      1. 7.2.1 Public Inheritance
      2. 7.2.2 Private Inheritance
      3. 7.2.3 Protected Inheritance
    3. 7.3 Type Compatible Rule
    4. 7.4 Constructor and Destructor of Derived Class
      1. 7.4.1 Constructor
      2. 7.4.2 Copy Constructor
      3. 7.4.3 Destructor
    5. 7.5 Identification and Access of Derived-Class Member
      1. 7.5.1 Scope Resolution
      2. 7.5.2 Virtual Base Class
      3. 7.5.3 Constructors of Virtual Base Class and Derived Class
    6. 7.6 Program Example: Solving Linear Equations using Gaussian Elimination Method
      1. 7.6.1 Fundamental Principles
      2. 7.6.2 Analysis of the Program Design
      3. 7.6.3 Source Code and Explanation
      4. 7.6.4 Execution Result and Analysis
    7. 7.7 Program Example: Personnel Information Management Program
      1. 7.7.1 Problem Description
      2. 7.7.2 Class Design
      3. 7.7.3 Source Code and Explanation
      4. 7.7.4 Execution Result and Analysis
    8. 7.8 Summary
    9. Exercises
  13. 8 Polymorphism
    1. 8.1 An Overview of Polymorphism
      1. 8.1.1 Types of Polymorphism
      2. 8.1.2 Implementation of Polymorphism
    2. 8.2 Operator Overload
      1. 8.2.1 Rules of Operator Overload
      2. 8.2.2 Operator Overloaded as Member Function
      3. 8.2.3 Operator Overloaded as Friend Function
    3. 8.3 Virtual Function
      1. 8.3.1 Ordinary Virtual Function Member
      2. 8.3.2 Virtual Destructor
    4. 8.4 Abstract Classes
      1. 8.4.1 Pure Virtual Functions
      2. 8.4.2 Abstract Classes
    5. 8.5 Program Instance: Variable Stepwise Trapezoid Method to Calculate Functional Definite Integral
      1. 8.5.1 Basic Principle
      2. 8.5.2 Analysis of Program Design
      3. 8.5.3 Source Code and Explanation
      4. 8.5.4 Execution Result and Analysis
    6. 8.6 Program Instance: Improvement on Staff Information Management System for a Small Corporation
    7. 8.7 Summary
    8. Exercises
  14. 9 Collections and Their Organization
    1. 9.1 Function Templates and Class Templates
      1. 9.1.1 Function Template
      2. 9.1.2 Class Template
    2. 9.2 Linear Collection
      1. 9.2.1 Definition of Linear Collection
      2. 9.2.2 Direct Accessible Linear Collection – Array
      3. 9.2.3 Sequential Access Collection – Linked List
      4. 9.2.4 Stack
      5. 9.2.5 Queues
    3. 9.3 Organizing Data in Linear Collections
      1. 9.3.1 Insertion Sort
      2. 9.3.2 Selection Sort
      3. 9.3.3 Exchange Sort
      4. 9.3.4 Sequential Search
      5. 9.3.5 Binary Search
    4. 9.4 Application – Improving the HR Management Program of a Small Company
    5. 9.5 Summary
    6. Exercises
  15. 10 Generic Programming and the Standard Template Library
    1. 10.1 Generic Programming
      1. 10.1.1 Introduction
      2. 10.1.2 Namespace
      3. 10.1.3 Differences of Naming Conventions Between C/C++
      4. 10.1.4 Concepts of STL
      5. 10.1.5 Containers
      6. 10.1.6 Adapters
      7. 10.1.7 Iterators
      8. 10.1.8 Algorithms
      9. 10.1.9 Interfaces of Containers
    2. 10.2 Containers in STL
      1. 10.2.1 Sequential Containers
      2. 10.2.2 Adapters of Containers
    3. 10.3 Iterators
      1. 10.3.1 Types of Iterators
      2. 10.3.2 Auxiliary Functions in Iterators
    4. 10.4 Algorithms in STL
      1. 10.4.1 Using the Algorithms
      2. 10.4.2 Nonmutating Sequence Algorithms
      3. 10.4.3 Mutating Sequence Algorithms
      4. 10.4.4 Sorting Related Algorithms
      5. 10.4.5 Numerical Algorithms
    5. 10.5 Function Objects
    6. 10.6 Application – Improving the HR Management Program of a Small Company
    7. 10.7 Summary
    8. Exercises
  16. 11 The I/O Stream Library and Input/Output
    1. 11.1 I/O Stream’s Concept and the Structure of a Stream Library
    2. 11.2 Output Stream
      1. 11.2.1 Construct Output Object
      2. 11.2.2 The Use of Inserter and Manipulator
      3. 11.2.3 Output File Stream Member Function
      4. 11.2.4 Binary Output File
    3. 11.3 Input Stream
      1. 11.3.1 Construct Input Stream Object
      2. 11.3.2 Extraction Operator
      3. 11.3.3 Input Stream Manipulator
      4. 11.3.4 Input Stream Member Function
    4. 11.4 Input/output Stream
    5. 11.5 Example-improve Employee Information Management System
    6. 11.6 Summary
    7. Exercises
  17. 12 Exception Handling
    1. 12.1 Basic Concepts of Exception Handling
    2. 12.2 The Implementation of Exception Handling in C++
      1. 12.2.1 The Syntax of Exception Handling
      2. 12.2.2 Exception Interface Declaration
    3. 12.3 Destruction and Construction in Exception Handling
    4. 12.4 Exception Handling of Standard Library
    5. 12.5 Program Example Improvement to Personal Information Administration Program in a Small Company
    6. 12.6 Summary
    7. Exercises
  18. Index

Product information

  • Title: C++ Programming
  • Author(s): Yuan Dong, Fang Yang, Li Zheng, Tsinghua University Tsinghua University Press
  • Release date: February 2019
  • Publisher(s): De Gruyter
  • ISBN: 9783110470666