You are previewing Essential C++.
O'Reilly logo
Essential C++

Book Description

"Readers can pick up this book and become familiar with C++ in a short time. Stan has taken a very broad and complicated topic and reduced it to the essentials that budding C++ programmers need to know to write real programs. His case study is effective and provides a familiar thread throughout the book." --Steve Vinoski, IONA

For the practicing programmer with little time to spare, Essential C++ offers a fast-track to learning and working with C++ on the job. This book is specifically designed to bring you up to speed in a short amount of time. It focuses on the elements of C++ programming that you are most likely to encounter and examines features and techniques that help solve real-world programming challenges.

Essential C++ presents the basics of C++ in the context of procedural, generic, object-based, and object-oriented programming. It is organized around a series of increasingly complex programming problems, and language features are introduced as solutions to these problems. In this way you will not only learn about the functions and structure of C++, but will understand their purpose and rationale.

You will find in-depth coverage of key topics such as:

  • Generic programming and the Standard Template Library (STL)

  • Object-based programming and class design

  • Object-oriented programming and the design of class hierarchies

  • Function and class template design and use

  • Exception handling and Run-Time Type Identification

In addition, an invaluable appendix provides complete solutions to, and detailed explanations of, the programming exercises found at the end of each chapter. A second appendix offers a quick reference handbook for the generic algorithms, providing an example of how each is used.

This concise tutorial will give you a working knowledge of C++ and a firm foundation on which to further your professional expertise.



0201485184B04062001

Table of Contents

  1. Copyright
  2. Preface
  3. Basic C++ Programming
    1. How to Write a C++ Program
    2. Defining and Initializing a Data Object
    3. Writing Expressions
    4. Writing Conditional and Loop Statements
    5. How to Use Arrays and Vectors
    6. Pointers Allow for Flexibility
    7. Writing and Reading Files
  4. Procedural Programming
    1. How to Write a Function
    2. Invoking a Function
    3. Providing Default Parameter Values
    4. Using Local Static Objects
    5. Declaring a Function Inline
    6. Providing Overloaded Functions
    7. Defining and Using Template Functions
    8. Pointers to Functions Add Flexibility
    9. Setting Up a Header File
  5. Generic Programming
    1. The Arithmetic of Pointers
    2. Making Sense of Iterators
    3. Operations Common to All Containers
    4. Using the Sequential Containers
    5. Using the Generic Algorithms
    6. How to Design a Generic Algorithm
    7. Using a Map
    8. Using a Set
    9. How to Use Iterator Inserters
    10. Using the iostream Iterators
  6. Object-Based Programming
    1. How to Implement a Class
    2. What Are Class Constructors and the Class Destructor?
    3. What Are mutable and const?
    4. What Is the this Pointer?
    5. Static Class Members
    6. Building an Iterator Class
    7. Collaboration Sometimes Requires Friendship
    8. Implementing a Copy Assignment Operator
    9. Implementing a Function Object
    10. Providing Class Instances of the iostream Operators
    11. Pointers to Class Member Functions
  7. Object-Oriented Programming
    1. Object-Oriented Programming Concepts
    2. A Tour of Object-Oriented Programming
    3. Polymorphism without Inheritance
    4. Defining an Abstract Base Class
    5. Defining a Derived Class
    6. Using an Inheritance Hierarchy
    7. How Abstract Should a Base Class Be?
    8. Initialization, Destruction, and Copy
    9. Defining a Derived Class Virtual Function
    10. Run-Time Type Identification
  8. Programming with Templates
    1. Parameterized Types
    2. The Template Class Definition
    3. Handling Template Type Parameters
    4. Implementing the Template Class
    5. A Function Template Output Operator
    6. Constant Expressions and Default Parameters
    7. Template Parameters as Strategy
    8. Member Template Functions
  9. Exception Handling
    1. Throwing an Exception
    2. Catching an Exception
    3. Trying for an Exception
    4. Local Resource Management
    5. The Standard Exceptions
  10. Exercise Solutions
    1. Exercise 1.4
    2. Exercise 1.5
    3. Exercise 1.6
    4. Exercise 1.7
    5. Exercise 1.8
    6. Exercise 2.1
    7. Exercise 2.2
    8. Exercise 2.3
    9. Exercise 2.4
    10. Exercise 2.5
    11. Exercise 2.6
    12. Exercise 3.1
    13. Exercise 3.2
    14. Exercise 3.3
    15. Exercise 3.4
    16. Exercise 4.1
    17. Exercise 4.2
    18. Exercise 4.3
    19. Exercise 4.4
    20. Exercise 4.5
    21. Exercise 5.1
    22. Exercise 5.2
    23. Exercise 5.3
    24. Exercise 5.4
    25. Exercise 6.1
    26. Exercise 6.2
    27. Exercise 7.1
    28. Exercise 7.2
    29. Exercise 7.3
  11. Generic Algorithms Handbook
    1. accumulate()
    2. adjacent_difference()
    3. adjacent_find()
    4. binary_search()
    5. copy()
    6. copy_backward()
    7. count()
    8. count_if()
    9. equal()
    10. fill()
    11. fill_n()
    12. find()
    13. find_end()
    14. find_first_of()
    15. find_if()
    16. for_each()
    17. generate()
    18. generate_n()
    19. includes()
    20. inner_product()
    21. inplace_merge()
    22. iter_swap()
    23. lexicographical_compare()
    24. max(), min()
    25. max_element() , min_element()
    26. merge()
    27. nth_element()
    28. partial_sort(), partial_sort_copy()
    29. partial_sum()
    30. partition(), stable_partition()
    31. random_shuffle()
    32. remove(), remove_copy()
    33. remove_if(), remove_copy_if()
    34. replace(), replace_copy()
    35. replace_if(), replace_copy_if()
    36. reverse(), reverse_copy()
    37. rotate(), rotate_copy()
    38. search()
    39. search_n()
    40. set_difference()
    41. set_intersection()
    42. set_symmetric_difference()
    43. set_union()
    44. sort(), stable_sort()
    45. transform()
    46. unique(), unique_copy()
  12. Index