Book description
Based on the authors’ highly popular C++-standard-compliant textbook, C++ How to Program, 6/e, Visual C++ How to Program 2/ E builds off this successful approach to offer readers a comprehensive introduction to Visual C++. Through their ongoing consultation with the Microsoft Visual C++ team, the Deitels have developed an approach that focuses on native C++ and presents examples of .NET managed code programming with C++/CLI, where appropriate. The book takes an easy-to-follow, carefully developed early classes and objects approach. This includes comprehensive coverage of the Visual C++ environment.
Like other books in the How to Program series, the new edition retains the Deitels' classic approach to developing good programming skills. These tools have been refined over a combined six decades of academic and industry teaching experience. This approach has been the foundation of several programmers in industry today.
Table of contents
- Copyright
- Deitel ® Series Page
- Deitel Resource Centers
- Preface
- Before You Begin
-
1. Introduction to Computers, the Internet and Visual C++
- 1.1. Introduction
- 1.2. What Is a Computer?
- 1.3. Computer Organization
- 1.4. Early Operating Systems
- 1.5. Personal Computing, Distributed Computing and Client/Server Computing
- 1.6. The Internet and the World Wide Web
- 1.7. Hardware Trends
- 1.8. Microsoft’s Windows® Operating System
- 1.9. Machine Languages, Assembly Languages and High-Level Languages
- 1.10. Visual C++
- 1.11. C++ Standard Library
- 1.12. Java, C# and Visual Basic
- 1.13. Other High-Level Languages
- 1.14. Microsoft’s .NET
- 1.15. The .NET Framework and the Common Language Runtime
- 1.16. Key Software Trend: Object Technology
- 1.17. Typical Visual C++ Development Life Cycle
- 1.18. Test-Driving a Visual C++ Application
- 1.19. Software Technologies
- 1.20. Future of Visual C++: Open Source Boost Libraries, TR1 and C++0x
- 1.21. (Only Required Section of the Case Study) Software Engineering Case Study: Introduction to Object Technology and the UML
- 1.22. Wrap-Up
-
Summary
- Section 1.1 Introduction
- Section 1.2 What Is a Computer?
- Section 1.3 Computer Organization
- Section 1.4 Early Operating Systems
- Section 1.5 Personal Computing, Distributed Computing and Client/Server Computing
- Section 1.6 The Internet and the World Wide Web
- Section 1.7 Hardware Trends
- Section 1.8 Microsoft’s Windows® Operating System
- Section 1.9 Machine Languages, Assembly Languages and High-Level Languages
- Section 1.10 Visual C++
- Section 1.12 Java, C# and Visual Basic
- Section 1.13 Other High-Level Languages
- Section 1.14 Microsoft’s .NET
- Section 1.15 The .NET Framework and the Common Language Runtime
- Section 1.16 Key Software Trend: Object Technology
- Section 1.17 Typical Visual C++ Development Life Cycle
- Section 1.20 Future of Visual C++: Open Source Boost Libraries, TR1 and C++0x
- Section 1.21 (Only Required Section of the Case Study) Software Engineering Case Study: Introduction to Object Technology and the UML
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
- 2. Dive Into® Visual C++® 2008 Express
-
3. Introduction to Visual C++ Programming
- 3.1. Introduction
- 3.2. First Program in Visual C++: Printing a Line of Text
- 3.3. Modifying Our First Visual C++ Program
- 3.4. Another Visual C++ Program: Adding Integers
- 3.5. Memory Concepts
- 3.6. Arithmetic
- 3.7. Decision Making: Equality and Relational Operators
- 3.8. (Optional) Software Engineering Case Study: Examining the ATM Requirements Specification
- 3.9. Wrap-Up
- Summary
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
-
4. Introduction to Classes and Objects
- 4.1. Introduction
- 4.2. Classes, Objects, Member Functions and Data Members
- 4.3. Overview of the Chapter Examples
- 4.4. Defining a Class with a Member Function
- 4.5. Defining a Member Function with a Parameter
-
4.6. Data Members, set Functions and get Functions
- GradeBook Class with a Data Member, a set Function and a get Function
- Access Specifiers public and private
- Member Functions setCourseName and getCourseName
- Member Function displayMessage
- Testing Class GradeBook
- Software Engineering with set and get Functions
- GradeBook’s UML Class Diagram with a Data Member and set and get Functions
- 4.7. Initializing Objects with Constructors
- 4.8. Placing a Class in a Separate File for Reusability
- 4.9. Separating Interface from Implementation
- 4.10. Validating Data with set Functions
- 4.11. Defining a Managed Class with Member Functions in C++/CLI
- 4.12. Instance Variables and Properties in C++/CLI
- 4.13. (Optional) Software Engineering Case Study: Identifying the Classes in the ATM Requirements Specification
- 4.14. Wrap-Up
-
Summary
- Section 4.2 Classes, Objects, Member Functions and Data Members
- Section 4.4 Defining a Class with a Member Function
- Section 4.5 Defining a Member Function with a Parameter
- Section 4.6 Data Members, set Functions and get Functions
- Section 4.7 Initializing Objects with Constructors
- Section 4.8 Placing a Class in a Separate File for Reusability
- Section 4.9 Separating Interface from Implementation
- Section 4.10 Validating Data with set Functions
- Section 4.11 Defining a Managed Class with Member Functions in C++/CLI
- Section 4.12 Instance Variables and Properties in C++/CLI
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
-
5. Control Statements: Part 1
- 5.1. Introduction
- 5.2. Algorithms
- 5.3. Pseudocode
- 5.4. Control Structures
- 5.5. if Selection Statement
- 5.6. if ...else Double-Selection Statement
- 5.7. while Repetition Statement
- 5.8. Formulating Algorithms: Counter-Controlled Repetition
-
5.9. Formulating Algorithms: Sentinel-Controlled Repetition
- Developing the Pseudocode Algorithm with Top-Down, Stepwise Refinement: The Top and First Refinement
- Proceeding to the Second Refinement
- Implementing Sentinel-Controlled Repetition in Class GradeBook
- Program Logic for Sentinel-Controlled Repetition vs. Counter-Controlled Repetition
- Floating-Point Number Precision and Memory Requirements
- Converting Between Fundamental Types Explicitly and Implicitly
- Formatting for Floating-Point Numbers
- 5.10. Formulating Algorithms: Nested Control Statements
- 5.11. Assignment Operators
- 5.12. Increment and Decrement Operators
- 5.13. (Optional) Software Engineering Case Study: Identifying Class Attributes in the ATM System
- 5.14. Wrap-Up
-
Summary
- Section 5.2 Algorithms
- Section 5.3 Pseudocode
- Section 5.4 Control Structures
- Section 5.5 if Selection Statement
- Section 5.6 if ...else Double-Selection Statement
- Section 5.7 while Repetition Statement
- Section 5.8 Formulating Algorithms: Counter-Controlled Repetition
- Section 5.9 Formulating Algorithms: Sentinel-Controlled Repetition
- Section 5.10 Formulating Algorithms: Nested Control Statements
- Section 5.11 Assignment Operators
- Section 5.12 Increment and Decrement Operators
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
-
6. Control Statements: Part 2
- 6.1. Introduction
- 6.2. Essentials of Counter-Controlled Repetition
- 6.3. for Repetition Statement
- 6.4. Examples Using the for Statement
- 6.5. do...while Repetition Statement
- 6.6. switch Multiple-Selection Statement
- 6.7. break and continue Statements
- 6.8. Logical Operators
- 6.9. Confusing the Equality (==) and Assignment (=) Operators
- 6.10. Structured Programming Summary
- 6.11. (Optional) Software Engineering Case Study: Identifying Objects’ States and Activities in the ATM System
- 6.12. Wrap-Up
-
Summary
- Section 6.2 Essentials of Counter-Controlled Repetition
- Section 6.3 for Repetition Statement
- Section 6.4 Examples Using the for Statement
- Section 6.5 do...while Repetition Statement
- Section 6.6 switch Multiple-Selection Statement
- Section 6.7 break and continue Statements
- Section 6.8 Logical Operators
- Section 6.9 Confusing the Equality (==) and Assignment (=) Operators
- Section 6.10 Structured Programming Summary
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
-
7. Functions and an Introduction to Recursion
- 7.1. Introduction
- 7.2. Program Components in Visual C++
- 7.3. Math Library Functions
- 7.4. Function Definitions with Multiple Parameters
- 7.5. Function Prototypes and Argument Coercion
- 7.6. C++ Standard Library Header Files
- 7.7. Case Study: Random Number Generation
- 7.8. Case Study: Game of Chance; Introducing enum
- 7.9. Storage Classes
- 7.10. Scope Rules
- 7.11. Function-Call Stack and Activation Records
- 7.12. Functions with Empty Parameter Lists
- 7.13. Inline Functions
- 7.14. References and Reference Parameters
- 7.15. Default Arguments
- 7.16. Unary Scope Resolution Operator
- 7.17. Function Overloading
- 7.18. Function Templates
- 7.19. Recursion
- 7.20. Example Using Recursion: Fibonacci Series
- 7.21. Recursion vs. Iteration
- 7.22. Enumerations in C++/CLI
-
7.23. (Optional) Software Engineering Case Study: Identifying Class Operations in the ATM System
- Identifying Operations
- Modeling Operations
- Operations of Class BankDatabase and Class Account
- Operations of Class Screen
- Operations of Class Keypad
- Operations of Class CashDispenser and Class DepositSlot
- Operations of Class ATM
- Identifying and Modeling Operation Parameters
- Software Engineering Case Study Self-Review Exercises
- Answers to Software Engineering Case Study Self-Review Exercises
- 7.24. Wrap-Up
-
Summary
- Section 7.1 Introduction
- Section 7.2 Program Components in Visual C++
- Section 7.3 Math Library Functions
- Section 7.4 Function Definitions with Multiple Parameters
- Section 7.5 Function Prototypes and Argument Coercion
- Section 7.6 C++ Standard Library Header Files
- Section 7.7 Case Study: Random Number Generation
- Section 7.8 Case Study: Game of Chance; Introducing enum
- Section 7.9 Storage Classes
- Section 7.10 Scope Rules
- Section 7.11 Function-Call Stack and Activation Records
- Section 7.12 Functions with Empty Parameter Lists
- Section 7.13 Inline Functions
- Section 7.14 References and Reference Parameters
- Section 7.15 Default Arguments
- Section 7.16 Unary Scope Resolution Operator
- Section 7.17 Function Overloading
- Section 7.18 Function Templates
- Section 7.19 Recursion
- Section 7.20 Example Using Recursion: Fibonacci Series
- Section 7.21 Recursion vs. Iteration
- Section 7.22 Enumerations in C++/CLI
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
-
8. Arrays and Vectors
- 8.1. Introduction
- 8.2. Arrays
- 8.3. Declaring Arrays
-
8.4. Examples Using Arrays
- 8.4.1. Declaring an Array and Using a Loop to Initialize the Array’s Elements
- 8.4.2. Initializing an Array in a Declaration with an Initializer List
- 8.4.3. Specifying an Array’s Size with a Constant Variable and Setting Array Elements with Calculations
- 8.4.4. Summing the Elements of an Array
- 8.4.5. Using Bar Charts to Display Array Data Graphically
- 8.4.6. Using the Elements of an Array as Counters
- 8.4.7. Using Arrays to Summarize Survey Results
- 8.4.8. Static Local Arrays and Automatic Local Arrays
- 8.5. Passing Arrays to Functions
- 8.6. Case Study: Class GradeBook Using an Array to Store Grades
- 8.7. Searching Arrays with Linear Search
- 8.8. Sorting Arrays with Insertion Sort
- 8.9. Multidimensional Arrays
- 8.10. Case Study: Class GradeBook Using a Two-Dimensional Array
- 8.11. Introduction to C++ Standard Library Class Template vector
- 8.12. Introduction to Managed Arrays with C++/CLI
- 8.13. for each Statement
- 8.14. Multidimensional Arrays in C++/CLI
- 8.15. (Optional) Software Engineering Case Study: Collaboration Among Objects in the ATM System
- 8.16. Wrap-Up
-
Summary
- Section 8.1 Introduction
- Section 8.2 Arrays
- Section 8.3 Declaring Arrays
- Section 8.4 Examples Using Arrays
- Section 8.5 Passing Arrays to Functions
- Section 8.6 Case Study: Class GradeBook Using an Array to Store Grades
- Section 8.7 Searching Arrays with Linear Search
- Section 8.8 Sorting Arrays with Insertion Sort
- Section 8.9 Multidimensional Arrays
- Section 8.11 Introduction to C++ Standard Library Class Template vector
- Section 8.12 Introduction to Managed Arrays with C++/CLI
- Section 8.13 for each Statement
- Section 8.14 Multidimensional Arrays in C++/CLI
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
- Recursion Exercises
- vector Exercises
- Managed Array Exercises
-
9. Pointers and Pointer-Based Strings
- 9.1. Introduction
- 9.2. Pointer Variable Declarations and Initialization
- 9.3. Pointer Operators
- 9.4. Passing Arguments to Functions by Reference with Pointers
- 9.5. Using const with Pointers
- 9.6. Selection Sort Using Pass-by-Reference
- 9.7. sizeof Operator
- 9.8. Pointer Expressions and Pointer Arithmetic
- 9.9. Relationship Between Pointers and Arrays
- 9.10. Arrays of Pointers
- 9.11. Case Study: Card Shuffling and Dealing Simulation
- 9.12. Function Pointers
- 9.13. Introduction to Pointer-Based String Processing
- 9.14. Introduction to C++/CLI Handles
- 9.15. Passing Arguments to Functions by Reference with Handles
- 9.16. Tracking References and References to Handles
- 9.17. Interior Pointers
- 9.18. Wrap-Up
-
Summary
- Section 9.2 Pointer Variable Declarations and Initialization
- Section 9.3 Pointer Operators
- Section 9.4 Passing Arguments to Functions by Reference with Pointers
- Section 9.5 Using const with Pointers
- Section 9.6 Selection Sort Using Pass-by-Reference
- Section 9.7 sizeof Operator
- Section 9.8 Pointer Expressions and Pointer Arithmetic
- Section 9.9 Relationship Between Pointers and Arrays
- Section 9.10 Arrays of Pointers
- Section 9.11 Case Study: Card Shuffling and Dealing Simulation
- Section 9.12 Function Pointers
- Section 9.13 Introduction to Pointer-Based String Processing
- Section 9.14 Introduction to C++/CLI Handles
- Section 9.15 Passing Arguments to Functions by Reference with Handles
- Section 9.16 Tracking References and References to Handles
- Section 9.17 Interior Pointers
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
- Special Section: Building Your Own Computer
- More Pointer Exercises
- String-Manipulation Exercises
- Special Section: Advanced String-Manipulation Exercises
- A Challenging String-Manipulation Project
- Handle Exercise
-
10. Classes: A DeeperLook, Part 1
- 10.1. Introduction
- 10.2. Time Class Case Study
- 10.3. Class Scope and Accessing Class Members
- 10.4. Separating Interface from Implementation
- 10.5. Access Functions and Utility Functions
- 10.6. Time Class Case Study: Constructors with Default Arguments
- 10.7. Destructors
- 10.8. When Constructors and Destructors Are Called
- 10.9. Time Class Case Study: A Subtle Trap—Returning a Reference to a private Data Member
- 10.10. Default Memberwise Assignment
- 10.11. Class View and Object Browser
- 10.12. (Optional) Software Engineering Case Study: Starting to Program the Classes of the ATM System
- 10.13. Wrap-Up
-
Summary
- Section 10.2 Time Class Case Study
- Section 10.3 Class Scope and Accessing Class Members
- Section 10.4 Separating Interface from Implementation
- Section 10.5 Access Functions and Utility Functions
- Section 10.6 Time Class Case Study: Constructors with Default Arguments
- Section 10.7 Destructors
- Section 10.8 When Constructors and Destructors Are Called
- Section 10.9 Time Class Case Study: A Subtle Trap—Returning a Reference to a private Data Member
- Section 10.10 Default Memberwise Assignment
- Section 10.11 Class View and Object Browser
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
-
11. Classes: A DeeperLook, Part 2
- 11.1. Introduction
- 11.2. const (Constant) Objects and const Member Functions
- 11.3. Composition: Objects as Members of Classes
- 11.4. friend Functions and friend Classes
- 11.5. Using the this Pointer
- 11.6. Dynamic Memory Management with Operators new and delete
- 11.7. static Class Members
- 11.8. Data Abstraction and Information Hiding
- 11.9. Container Classes and Iterators
- 11.10. Proxy Classes
- 11.11. const and friend in C++/CLI
- 11.12. Dynamic Memory Management in C++/CLI
- 11.13. Stack Semantics in C++/CLI
- 11.14. Finalizers
- 11.15. Value Types vs. Reference Types in C++/CLI
- 11.16. Boxing and Unboxing in C++/CLI
- 11.17. Indexers
- 11.18. Wrap-Up
-
Summary
- Section 11.2 const (Constant) Objects and const Member Functions
- Section 11.3 Composition: Objects as Members of Classes
- Section 11.4 friend Functions and friend Classes
- Section 11.5 Using the this Pointer
- Section 11.6 Dynamic Memory Management with Operators new and delete
- Section 11.7 static Class Members
- Section 11.8 Data Abstraction and Information Hiding
- Section 11.9 Container Classes and Iterators
- Section 11.10 Proxy Classes
- Section 11.11, const and friend in C++/CLI
- Section 11.12 Dynamic Memory Management in C++/CLI
- Section 11.13 Stack Semantics in C++/CLI
- Section 11.14 Finalizers
- Section 11.15 Value Types vs. Reference Types in C++/CLI
- Section 11.16 Boxing and Unboxing in C++/CLI
- Section 11.17 Indexers
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
-
12. Operator Overloading; String and Array Objects
- 12.1. Introduction
- 12.2. Fundamentals of Operator Overloading
- 12.3. Restrictions on Operator Overloading
- 12.4. Operator Functions as Class Members vs. Global Functions
- 12.5. Overloading Stream Insertion and Stream Extraction Operators
- 12.6. Overloading Unary Operators
- 12.7. Overloading Binary Operators
-
12.8. Case Study: Array Class
- Creating Arrays, Outputting Their Size and Displaying Their Contents
- Using the Overloaded Stream Insertion Operator to Fill an Array
- Using the Overloaded Inequality Operator
- Initializing a New Array with a Copy of an Existing Array’s Contents
- Using the Overloaded Assignment Operator
- Using the Overloaded Equality Operator
- Using the Overloaded Subscript Operator
- Array Class Definition
- Overloading the Stream Insertion and Stream Extraction Operators as friends
- Array Default Constructor
- Array Copy Constructor
- Array Destructor
- getSize Member Function
- Overloaded Assignment Operator
- Overloaded Equality and Inequality Operators
- Overloaded Subscript Operators
- 12.9. Converting between Types
-
12.10. Case Study: String Class
- String Class Definition
- Overloading the Stream Insertion and Stream Extraction Operators as friends
- String Conversion Constructor
- String Copy Constructor
- String Destructor
- Overloaded Assignment Operator
- Overloaded Addition Assignment Operator
- Overloaded Negation Operator
- Overloaded Equality and Relational Operators
- Overloaded Subscript Operators
- Overloaded Function-Call Operator
- String Member Function getLength
- Notes on Our String Class
- 12.11. Overloading ++ and --
- 12.12. Case Study: A Date Class
- 12.13. Standard Library Class string
- 12.14. explicit Constructors
- 12.15. C++/CLI Operators and Constructors
- 12.16. Wrap-Up
-
Summary
- Section 12.1 Introduction
- Section 12.2 Fundamentals of Operator Overloading
- Section 12.3 Restrictions on Operator Overloading
- Section 12.4 Operator Functions as Class Members vs. Global Functions
- Section 12.5 Overloading Stream Insertion and Stream Extraction Operators
- Section 12.6 Overloading Unary Operators
- Section 12.7 Overloading Binary Operators
- Section 12.8 Case Study: Array Class
- Section 12.9 Converting between Types
- Section 12.10 Case Study: String Class
- Section 12.11 Overloading ++ and --
- Section 12.13 Standard Library Class string
- Section 12.14 explicit Constructors
- Section 12.15 C++/CLI Operators and Constructors
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
-
13. Object-Oriented Programming: Inheritance
- 13.1. Introduction
- 13.2. Base Classes and Derived Classes
- 13.3. protected Members
-
13.4. Relationship between Base Classes and Derived Classes
- 13.4.1. Creating and Using a CommissionEmployee Class
- 13.4.2. Creating a BasePlusCommissionEmployee Class Without Using Inheritance
- 13.4.3. Creating a CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy
- 13.4.4. CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using protected Data
- 13.4.5. CommissionEmployee–BasePlusCommissionEmployee Inheritance Hierarchy Using private Data
- 13.5. Constructors and Destructors in Derived Classes
- 13.6. public, protected and private Inheritance
- 13.7. Software Engineering with Inheritance
- 13.8. Inheritance in C++/CLI
- 13.9. Wrap-Up
- Summary
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
-
14. Object-Oriented Programming: Polymorphism
- 14.1. Introduction
- 14.2. Polymorphism Examples
-
14.3. Relationships Among Objects in an Inheritance Hierarchy
- 14.3.1. Invoking Base-Class Functions from Derived-Class Objects
- 14.3.2. Aiming Derived-Class Pointers at Base-Class Objects
- 14.3.3. Derived-Class Member-Function Calls via Base-Class Pointers
- 14.3.4. Virtual Functions
- 14.3.5. Summary of the Allowed Assignments Between Base-Class and Derived-Class Objects and Pointers
- 14.4. Type Fields and switch Statements
- 14.5. Abstract Classes and Pure virtual Functions
-
14.6. Case Study: Payroll System Using Polymorphism
- 14.6.1. Creating Abstract Base Class Employee
- 14.6.2. Creating Concrete Derived Class SalariedEmployee
- 14.6.3. Creating Concrete Derived Class HourlyEmployee
- 14.6.4. Creating Concrete Derived Class CommissionEmployee
- 14.6.5. Creating Indirect Concrete Derived Class BasePlusCommissionEmployee
- 14.6.6. Demonstrating Polymorphic Processing
- 14.7. (Optional) Polymorphism, Virtual Functions and Dynamic Binding “Under the Hood”
- 14.8. Case Study: Payroll System Using Polymorphism and Runtime Type Information with Downcasting, dynamic_cast, typeid and type_info
- 14.9. Virtual Destructors
- 14.10. Polymorphism in C++/CLI
- 14.11. (Optional) Software Engineering Case Study: Incorporating Inheritance into the ATM System
- 14.12. Wrap-Up
-
Summary
- Section 14.1 Introduction
- Section 14.2 Polymorphism Examples
- Section 14.3 Relationships Among Objects in an Inheritance Hierarchy
- Section 14.4 Type Fields and switch Statements
- Section 14.5 Abstract Classes and Pure virtual Functions
- Section 14.7 (Optional) Polymorphism, Virtual Functions and Dynamic Binding “Under the Hood”
- Section 14.8 Case Study: Payroll System Using Polymorphism and Runtime Type Information with Downcasting, dynamic_cast, typeid and type_info
- Section 14.9 Virtual Destructors
- Section 14.10 Polymorphism in C++/CLI
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
-
15. Templates and Generics
- 15.1. Introduction
- 15.2. Function Templates
- 15.3. Overloading Function Templates
- 15.4. Class Templates
- 15.5. Nontype Parameters and Default Types for Class Templates
- 15.6. Notes on Templates and Inheritance
- 15.7. Notes on Templates and Friends
- 15.8. Notes on Templates and static Members
- 15.9. Templates in C++/CLI
- 15.10. .NET Generics in C++/CLI
- 15.11. Generic Type Constraints
- 15.12. Contrasting Templates and Generics
- 15.13. Wrap-Up
-
Summary
- Section 15.1 Introduction
- Section 15.2 Function Templates
- Section 15.3 Overloading Function Templates
- Section 15.4 Class Templates
- Section 15.5 Nontype Parameters and Default Types for Class Templates
- Section 15.6 Notes on Templates and Inheritance
- Section 15.7 Notes on Templates and Friends
- Section 15.8 Notes on Templates and static Members
- Section 15.9 Templates in C++/CLI
- Section 15.10 .NET Generics in C++/CLI
- Section 15.11 Generic Type Constraints
- Section 15.12 Contrasting Templates and Generics
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
-
16. Exception Handling
- 16.1. Introduction
- 16.2. Exception-Handling Overview
- 16.3. Example: Divide by Zero Without Exception Handling
-
16.4. Example: Handling an Attempt to Divide by Zero
- Defining an Exception Class to Represent the Type of Problem That Might Occur
- Demonstrating Exception Handling
- Enclosing Code in a try Block
- Defining a catch Handler to Process a DivideByZeroException
- Termination Model of Exception Handling
- Flow of Program Control When the User Enters a Nonzero Denominator
- Flow of Program Control When the User Enters a Denominator of Zero
- Uncaught Exceptions
- 16.5. When to Use Exception Handling
- 16.6. Rethrowing an Exception
- 16.7. Processing Unexpected Exceptions
- 16.8. Stack Unwinding
- 16.9. Constructors, Destructors and Exception Handling
- 16.10. Exceptions and Inheritance
- 16.11. Processing new Failures
- 16.12. Class auto_ptr and Dynamic Memory Allocation
- 16.13. Standard Library Exception Hierarchy
- 16.14. Other Error-Handling Techniques
- 16.15. .NET Exception Hierarchy with C++/CLI
- 16.16. finally Block in C++/CLI
- 16.17. Exception Properties in C++/CLI
- 16.18. User-Defined Exception Classes in .NET
- 16.19. Wrap-Up
-
Summary
- Section 16.1 Introduction
- Section 16.2 Exception-Handling Overview
- Section 16.3 Example: Divide by Zero Without Exception Handling
- Section 16.4 Example: Handling an Attempt to Divide by Zero
- Section 16.5 When to Use Exception Handling
- Section 16.6 Rethrowing an Exception
- Section 16.7 Processing Unexpected Exceptions
- Section 16.8 Stack Unwinding
- Section 16.9 Constructors, Destructors and Exception Handling
- Section 16.10 Exceptions and Inheritance
- Section 16.11 Processing new Failures
- Section 16.12 Class auto_ptr and Dynamic Memory Allocation
- Section 16.13 Standard Library Exception Hierarchy
- Section 16.15 .NET Exception Hierarchy with C++/CLI
- Section 16.16 finally Block in C++/CLI
- Section 16.17 Exception Properties in C++/CLI
- Section 16.18 User-Defined Exception Classes in .NET
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
-
17. Stream Input/Output and Files
- 17.1. Introduction
- 17.2. Streams
- 17.3. Stream Output
- 17.4. Stream Input
- 17.5. Unformatted I/O Using read, write and gcount
- 17.6. Introduction to Stream Manipulators
-
17.7. Stream Format States and Stream Manipulators
- 17.7.1. Trailing Zeros and Decimal Points (showpoint)
- 17.7.2. Justification (left, right and internal)
- 17.7.3. Padding (fill, setfill)
- 17.7.4. Integral Stream Base (dec, oct, hex, showbase)
- 17.7.5. Floating-Point Numbers; Scientific and Fixed Notation (scientific, fixed)
- 17.7.6. Uppercase/Lowercase Control (uppercase)
- 17.7.7. Specifying Boolean Format (boolalpha)
- 17.7.8. Setting and Resetting the Format State via Member Function flags
- 17.8. Stream Error States
- 17.9. Tying an Output Stream to an Input Stream
- 17.10. Data Hierarchy
- 17.11. Files and Streams
- 17.12. Creating a Sequential File
- 17.13. Reading Data from a Sequential File
- 17.14. Updating Sequential Files
- 17.15. Wrap-Up
-
Summary
- Section 17.1 Introduction
- Section 17.2 Streams
- Section 17.3 Stream Output
- Section 17.4 Stream Input
- Section 17.5 Unformatted I/O Using read, write and gcount
- Section 17.6 Introduction to Stream Manipulators
- Section 17.7 Stream Format States and Stream Manipulators
- Section 17.8 Stream Error States
- Section 17.9 Tying an Output Stream to an Input Stream
- Section 17.10 Data Hierarchy
- Section 17.11 Files and Streams
- Section 17.12 Creating a Sequential File
- Section 17.13 Reading Data from a Sequential File
- Section 17.14 Updating Sequential Files
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
-
18. Files and Streams in .NET
- 18.1. Introduction
- 18.2. Files and Streams
- 18.3. Classes File and Directory
- 18.4. Creating a Sequential-Access Text File
- 18.5. Reading Data from a Sequential-Access Text File
- 18.6. Serialization
- 18.7. Creating a Sequential-Access File Using Object Serialization
- 18.8. Reading and Deserializing Data from a Sequential Access Text File
- 18.9. Wrap-Up
-
Summary
- Section 18.1 Introduction
- Section 18.2 Files and Streams
- Section 18.3 Classes File and Directory
- Section 18.4 Creating a Sequential-Access Text File
- Section 18.5 Reading Data from a Sequential-Access Text File
- Section 18.6 Serialization
- Section 18.7 Creating a Sequential-Access File Using Object Serialization
- Section 18.8 Reading and Deserializing Data from a Sequential-Access Text File
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
-
19. Class string and String Stream Processing
- 19.1. Introduction
- 19.2. string Assignment and Concatenation
- 19.3. Comparing strings
- 19.4. Substrings
- 19.5. Swapping strings
- 19.6. string Characteristics
- 19.7. Finding Substrings and Characters in a string
- 19.8. Replacing Characters in a string
- 19.9. Inserting Characters into a string
- 19.10. Conversion to C-Style Pointer-Based char * Strings
- 19.11. Iterators
- 19.12. String Stream Processing
- 19.13. Fundamentals of Characters and Strings in C++/CLI
- 19.14. String Constructors
- 19.15. String Indexer, Length Property and CopyTo Function
- 19.16. Comparing Strings
- 19.17. Locating Characters and Substrings in Strings
- 19.18. Extracting Substrings from Strings
- 19.19. Concatenating Strings
- 19.20. Miscellaneous String Functions
- 19.21. Class StringBuilder
- 19.22. StringBuilder Class Length, Capacity, EnsureCapacity and Indexer
- 19.23. StringBuilder Class Append and AppendFormat Functions
- 19.24. StringBuilder Class Insert, Remove and Replace Functions
- 19.25. Char Functions
- 19.26. Wrap-Up
-
Summary
- Section 19.1 Introduction
- Section 19.2 string Assignment and Concatenation
- Section 19.3 Comparing strings
- Section 19.4 Substrings
- Section 19.5 Swapping strings
- Section 19.6 string Characteristics
- Section 19.7 Finding Substrings and Characters in a string
- Section 19.8 Replacing Characters in a string
- Section 19.9 Inserting Characters into a string
- Section 19.10 Conversion to C-Style Pointer-Based char * Strings
- Section 19.11 Iterators
- Section 19.12 String Stream Processing
- Section 19.13 Fundamentals of Characters and Strings in C++/CLI
- Section 19.14 String Constructors
- Section 19.15 String Indexer, Length Property, and CopyTo Function
- Section 19.16 Comparing Strings
- Section 19.17 Locating Characters and Substrings in Strings
- Section 19.18 Extracting Substrings from Strings
- Section 19.19 Concatenating Strings
- Section 19.20 Miscellaneous String Functions
- Section 19.21 Class StringBuilder
- Section 19.22 StringBuilder Class Length, Capacity, EnsureCapacity and Indexer
- Section 19.23 StringBuilder Class Append and AppendFormat Functions
- Section 19.24 StringBuilder Class Insert, Remove and Replace Functions
- Section 19.25 Char Functions
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
- 20. Searching and Sorting
-
21. Data Structures
- 21.1. Introduction
- 21.2. Self-Referential Classes
- 21.3. Dynamic Memory Allocation and Data Structures
- 21.4. Linked Lists
- 21.5. Stacks
- 21.6. Queues
- 21.7. Trees
- 21.8. Wrap-Up
- Summary
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
- Special Section: Building Your Own Compiler
-
22. Bits, Characters, C Strings and structs
- 22.1. Introduction
- 22.2. Structure Definitions
- 22.3. Initializing Structures
- 22.4. Using Structures with Functions
- 22.5. typedef
- 22.6. Example: High-Performance Card Shuffling and Dealing Simulation
- 22.7. Bitwise Operators
- 22.8. Bit Fields
- 22.9. Character-Handling Library Functions
- 22.10. Pointer-Based String-Conversion Functions
- 22.11. Search Functions of the Pointer-Based String-Handling Library
- 22.12. Memory Functions of the Pointer-Based String-Handling Library
- 22.13. Wrap-Up
-
Summary
- Section 22.2 Structure Definitions
- Section 22.3 Initializing Structures
- Section 22.4 Using Structures with Functions
- Section 22.5 typedef
- Section 22.7 Bitwise Operators
- Section 22.8 Bit Fields
- Section 22.9 Character-Handling Library Functions
- Section 22.10 Pointer-Based String-Conversion Functions
- Section 22.11 Search Functions of the Pointer-Based String-Handling Library
- Section 22.12 Memory Functions of the Pointer-Based String-Handling Library
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
-
23. Standard Template Library (STL)
- 23.1. Introduction to the Standard Template Library (STL)
- 23.2. Sequence Containers
- 23.3. Associative Containers
- 23.4. Container Adapters
-
23.5. Algorithms
- 23.5.1. fill, fill_n, generate and generate_n
- 23.5.2. equal, mismatch and lexicographical_compare
- 23.5.3. remove, remove_if, remove_copy and remove_copy_if
- 23.5.4. replace, replace_if, replace_copy and replace_copy_if
- 23.5.5. Mathematical Algorithms
- 23.5.6. Basic Searching and Sorting Algorithms
- 23.5.7. swap, iter_swap and swap_ranges
- 23.5.8. copy_backward, merge, unique and reverse
- 23.5.9. inplace_merge, unique_copy and reverse_copy
- 23.5.10. Set Operations
- 23.5.11. lower_bound, upper_bound and equal_range
- 23.5.12. Heapsort
- 23.5.13. min and max
- 23.5.14. STL Algorithms Not Covered in This Chapter
- 23.6. Class bitset
- 23.7. Function Objects
- 23.8. Introduction to STL/CLR
- 23.9. Wrap-Up
- 23.10. STL Web Resources
-
Summary
- Section 23.1 Introduction to the Standard Template Library (STL)
- Section 23.1.1 Introduction to Containers
- Section 23.2 Sequence Containers
- Section 23.3 Associative Containers
-
Section 23.4 Container Adapters
- Section 23.4.1 stack Adapter
- Section 23.4.2 queue Adapter
- Section 23.4.3 priority_queue Adapter
- Section 23.5.1 fill, fill_n, generate and generate_n
- Section 23.5.2 equal, mismatch and lexicographical_compare
- Section 23.5.3 remove, remove_if, remove_copy and remove_copy_if
- Section 23.5.4 replace, replace_if, replace_copy and replace_copy_if
- Section 23.5.5 Mathematical Algorithms
- Section 23.5.6 Basic Searching and Sorting Algorithms
- Section 23.5.7 swap, iter_swap and swap_ranges
- Section 23.5.8 copy_backward, merge, unique and reverse
- Section 23.5.9 inplace_merge, unique_copy and reverse_copy
- Section 23.5.10 Set Operations
- Section 23.5.11 lower_bound, upper_bound and equal_range
- Section 23.5.12 Heapsort
- Section 23.5.13 min and max
- Section 23.6 Class bitset
- Section 23.7 Function Objects
- Section 23.8 Introduction to STL/CLR
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
- Recommended Reading
-
24. Regular Expressions
- 24.1. Introduction
- 24.2. Simple Regular Expressions and Class Regex
- 24.3. Complex Regular Expressions
- 24.4. Validating User Input with Regular Expressions
- 24.5. Regex Member Functions Replace and Split
- 24.6. Wrap-Up
- Summary
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
- 25. Collections
-
26. Other Topics
- 26.1. Introduction
- 26.2. Other Cast Operators
- 26.3. namespaces
- 26.4. Operator Keywords
- 26.5. mutable Class Members
- 26.6. Pointers to Class Members (.* and ->*)
- 26.7. Multiple Inheritance
- 26.8. Multiple Inheritance and virtual Base Classes
- 26.9. Variable-Length Argument Lists
- 26.10. Using Command-Line Arguments
- 26.11. Delegates and Events in .NET
- 26.12. Wrap-Up
-
Summary
- Section 26.2 Other Cast Operators
- Section 26.3 namespaces
- Section 26.4 Operator Keywords
- Section 26.5 mutable Class Members
- Section 26.6 Pointers to Class Members (.* and ->*)
- Section 26.7 Multiple Inheritance
- Section 26.8 Multiple Inheritance and virtual Base Classes
- Section 26.9 Variable-Length Argument Lists
- Section 26.10 Using Command-Line Arguments
- Section 26.11 Delegates and Events in .NET
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
- A. Operator Precedence and Associativity Chart
- B. ASCII Character Set
- C. Fundamental Types
-
D. Number Systems
- D.1. Introduction
- D.2. Abbreviating Binary Numbers as Octal and Hexadecimal Numbers
- D.3. Converting Octal and Hexadecimal Numbers to Binary Numbers
- D.4. Converting from Binary, Octal or Hexadecimal to Decimal
- D.5. Converting from Decimal to Binary, Octal or Hexadecimal
- D.6. Negative Binary Numbers: Two’s Complement Notation
- Summary
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
-
E. Preprocessor
- E.1. Introduction
- E.2. The #include Preprocessor Directive
- E.3. The #define Preprocessor Directive: Symbolic Constants
- E.4. The #define Preprocessor Directive: Macros
- E.5. Conditional Compilation
- E.6. The #error and #pragma Preprocessor Directives
- E.7. Operators # and ##
- E.8. Predefined Symbolic Constants
- E.9. Assertions
- E.10. Wrap-Up
-
Summary
- Section E.2 The #include Preprocessor Directive
- Section E.3 The #define Preprocessor Directive: Symbolic Constants
- Section E.4 The #define Preprocessor Directive: Macros
- Section E.5 Conditional Compilation
- Section E.6 The #error and #pragma Preprocessor Directives
- Section E.7 Operators # and ##
- Section E.8 Predefined Symbolic Constants
- Section E.9 Assertions
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Exercises
-
F. ATM Case Study Code
- F.1. ATM Case Study Implementation
- F.2. Class ATM
- F.3. Class Screen
- F.4. Class Keypad
- F.5. Class CashDispenser
- F.6. Class DepositSlot
- F.7. Class Account
- F.8. Class BankDatabase
- F.9. Class Transaction
- F.10. Class BalanceInquiry
- F.11. Class Withdrawal
- F.12. Class Deposit
- F.13. Test Program ATMCaseStudy.cpp
- F.14. Wrap-Up
- G. UML 2: Additional Diagram Types
- H. Using the Visual Studio Debugger
Product information
- Title: Visual C++ 2008: How to Program, Second Edition
- Author(s):
- Release date: December 2007
- Publisher(s): Pearson
- ISBN: 9780136085652
You might also like
book
Build Windows 8 Apps with Microsoft Visual C++ Step by Step
Your hands-on, step-by-step guide to building Windows 8 apps with Microsoft Visual C++ Teach yourself how …
book
Microsoft Visual C++/CLI Step by Step
Your hands-on guide to Visual C++/CLI fundamentals Expand your expertise—and teach yourself the fundamentals of the …
book
Ivor Horton's Beginning Visual C++ 2012
The only book to teach C++ programming with Microsoft Visual Studio! There's a reason why Ivor …
book
C++ for Lazy Programmers: Quick, Easy, and Fun C++ for Beginners
Learn C++ the quick, easy, and “lazy” way. This book is an introductory programming text that …