Register your product to gain access to bonus material or receive a coupon.
Keeps students abreast of the most recent changes in C++ programming. Ex.___
Gives students a firm understanding of STL and helps them understand the predicted, major impact it will have on C++. Ex.___
Helps students recognize the underlying importance of inheritance and polymorphism to the object-oriented programming paradigm. Ex.___
Presents students with a solid explanation of how to use the popular Microsoft Visual C++ with the Microsoft Foundation Classes. Ex.___
Enables students to carefully examine and fully grasp the concept or programming technique under discussion. Ex.___
Helps students assimilate information in a more orderly manner by giving them a clear, visually organized presentation of material. Ex.___
Provides students and instructors with up-to-date text support. Ex.___
Enables students to use the standard input/output library to its fullest advantage. Ex.___
Shows students C++ in action in the real world. Ex.___
Shows students how to code and explains tricky parts of C++. Ex.___
Allows students to check their understanding of the section. Ex.___
Gives students valuable practice in coding entire programs that are both interesting and applicable. Ex.___
Alerts students to potential programming pitfalls and offers important tips and guidance for avoiding such mistakes; provides a handy “error” checklist. Ex.___
Broadens students' knowledge base. Ex.___
Enriches students' learning experience by adding visual appeal and clarifying discussions. Ex.___
Allows students to check whether they solved exercises correctly and look for alternative approaches. Ex.___
Provides students with a handy reference for in- and out-of-class use. Ex.___
As users of the highly successful first edition of this book can attest, this second edition is for both the student and the professional wanting to master the latest updates to the C++ programming language. The authors combine their years of experience to teach the power and flexibility of C++ through object-oriented programming applications. This new book reflects the clear presentation and excellent enhanced examples and programming exercises for which the authors have become well know.
1. Object-Oriented Programming.
2. From C to C++.
3. Classes.
4. Inheritance.
5. Polymorphism.
6. Operator Overloading.
7. Templates and the Standard Template Library.
8. The C++ Input/Output Class Hierarchy.
9. Object-Oriented Programming In The Microsoft Foundation Classes.
Appendix A. ASCII Table.
Appendix B. Selected C++ Functions and Methods.
Hints and Solutions to Odd-Numbered Exercises.
Index.
This book is based on C++ courses given by the authors at DePaul University and can be used for self-study or for a course on object-oriented programming in C++. We assume no prior knowledge of C++, but we do assume knowledge of C. Coverage of C at the level provided in R. Johnsonbaugh and M. Kalin, Applications Programming in ANSI C, 3rd ed. (Upper Saddle River, N.J.: Prentice Hall, 1996) provides sufficient background for this book. The book and its supplements a CDROM containing Microsoft's C++ compiler, an Instructor's Guide, and a World Wide Web site provide a comprehensive support system to help the reader master C++. In this book, as in our other C and C++ books, we make extensive use of examples, figures, self-study exercises, sample applications, lists of common programming errors, and programming exercises. We strive for clarity throughout the book and also illustrate a variety of good programming practices.
This book treats object-oriented principles (see Chapter 1); emphasizes sound programming practices; introduces templates and the standard template library (see Chapter 7); presents in depth the C++ input/output class hierarchy (Chapter 8); features major, useful examples (e.g., a stack class, Sections 3.2 and 7.2; and a random access file class, Section 8.6); and introduces objectoriented programming in the Microsoft Foundation Classes in Chapter 9.
The C++ language presented here is based on the approved standard. As such it contains the latest additions and changes to the language including
Overview
During the 1980s and early 1990s, C became the language of choice for many applications and systems programmers. Most major software available for personal computers was written in C: spreadsheets, word processors, databases, communications packages, statistical software, graphics packages, and so on. Virtually all software written for the UNIX environment was likewise written in C, and many mainframe systems meant to be ported from one platform to another were also coded in C. In the early 1980s, Bjarne Stroustrup of AT&T Bell Labs developed C++ as an extension of C that supports object-oriented programming, a type of programming that is well suited to the large, complex software systems now written for all platforms, from the cheapest personal computers to the most expensive mainframes. C++ also corrects some shortcomings in C, which C++ includes as a subset, and it supports abstract data types and generic functions through templates.
C++ is a highly complex language. Fortunately, most C++ programmers can benefit from its power without mastering each and every one of its features. We focus on the most useful aspects of the language, but we place some of the more esoteric and specialized parts of the language in endof-chapter sections labeled C++ Postscript. We focus on using C++ to write practical programs based on sound design techniques, rather than on tricks and surprises in C++.
About This Book
This book includes
Changes from the First Edition
Chapter 1 introduces key concepts associated with object-oriented design and programming: classes, abstract data types, objects, encapsulation, the client/server model, message passing, inheritance, polymorphism, and others. The chapter contrasts object-oriented design with topdown functional decomposition and offers examples to illustrate the differences between the approaches.
Important changes and additions to C++ are detailed in Chapter 2. Chapter 2 also introduces namespaces, type string, the new and delete operators, exception handling, and basic C++ input/output. The reader can begin using these important C++ features right away.
Chapter 3 covers the basics of classes so that the reader can begin using classes at once. The chapter explains how to declare classes; how to write constructors, destructors, and other methods; static data members and methods; and pointers to objects. Chapter 3 relies heavily on examples to explain how classes may be used to implement abstract data types and to meet the object-oriented goal of encapsulation.
Inheritance (including multiple inheritance) is the topic of Chapter 4. Through examples and sample applications (e.g., a sequence hierarchy), the chapter illustrates basic programming techniques.
Polymorphism is covered in Chapter 5. Section 5.1 carefully explains the distinction between run-time and compile-time binding. Sections 5.4 and 5.5 explain abstract base classes and run-time type identification.
Chapter 6 is devoted to operator overloading. The chapter shows how to overload common operators (e.g., +, /) as well as the subscript, function call, memory management, preincrement, and postincrement operators among others. Many examples and sample applications highlight the power of operator overloading.
Templates and STL (standard template library) are explained in Chapter 7. A template stack class (Section 7.2) shows templates in action, and a sample application (stock performance reports in Section 7.4) demonstrates how to use STL.
Chapter 8 serves several purposes. First, the chapter examines the C++ input/output library in detail so that the interested reader can exploit the powerful classes contained therein. This treatment culminates in a sample application that builds a random access file class through inheritance from a system file class. Second, the chapter uses the input/output library as a major, sophisticated example of object-oriented design realized in C++. Third, the hierarchy provides an excellent example of the use of templates. Chapter 8 pays close attention to manipulators, which are powerful ways to do sophisticated input/output in C++. We believe that Chapter 8 offers an unrivaled examination of C++'s input/output.
Chapter 9 covers object-oriented programming in the Microsoft Foundation Classes (MFC). We clarify the relationship between MFC and the Win32 Applications Programmer Interface, Microsoft's C libraries for accessing systems services. We also introduce the basic concepts and constructs of event-driven programming. The chapter focuses on object persistence through serialization and interapplication communication under Microsoft's Common Object Model. We provide two sample applications together with an overview of MFC and Visual C++.
Two appendices are provided for reference. Appendix A contains the ASCII table. Appendix B contains a list of some of the most useful C++ functions and class methods. We describe the parameters and return values, the header to include, and what the function or method does.
We rely heavily on short examples, figures, and tables to illustrate specific points about the syntax and semantics of C++. From our experience teaching C++ and other languages, we are convinced that no single method is appropriate for clarifying every aspect about a language.
Most of our students agree with us that learning and using C++ is exciting. We have tried to incorporate this view by using engaging examples, sample applications, programming exercises, and short segments of code.
Chapter Structure
The basic chapter organization is as follows:
Contents
Overview
Section
Section Exercises
Section
Section Exercises
C++ Postscript
Common Programming Errors
Programming Exercises
In every chapter except 1 and 2, several sections are devoted to sample applications. Each of these sections contains a statement of a problem, sample input and output, a solution to the problem, and a well-documented implementation of a solution to the problem in C++. Most of these sections conclude with an extended discussion.
The sample applications include the following:
The Common Programming Errors sections highlight those aspects of the language that are easily misunderstood.
The book contains over 100 programming exercises drawn from a wide variety of applications.
Examples
The book contains nearly 300 examples, which clarify particular facets of C++ for the reader and show the purpose of various C++ features. A box marks the end of each example.
Exercises
The book contains over 500 section review exercises, the answers to which are short answers, code segments, and, in a few cases, entire programs. These exercises are suitable as homework problems or as self-tests. The answers to the odd-numbered exercises are given in the back of the book, and the answers to the even-numbered exercises are given in the Instructor's Guide. Our experience in teaching C++ has convinced us of the importance of these exercises.
The applications covered in the programming exercises at the ends of the chapters include the following:
CD-ROM
The book comes with a CD-ROM that has the Student Edition of the current release of Microsoft's Visual C++ Integrated Development Environment, which includes a C++ compiler, a debugger and class browser, help facilities, the Microsoft Foundation Classes and the ActiveX Template Library, and many other resources for applications development. All of our sample applications, including the Microsoft-specific applications of Chapter 9, may be compiled and run under Visual C++.
Instructor Supplement
An Instructor's Guide is available from the publisher at no cost to adopters of this book. The Instructor's Guide contains solutions to even-numbered section exercises, sample syllabi, and transparency masters.
World Wide Web Site
The World Wide Web site
contains the source code, header files, and data files for all of the book's sample applications; the source code for some of the longer examples; sample syllabi; transparencies; a sample chapter; information about using Microsoft Visual C++; additional technical details about the Microsoft Foundation Classes; and an errata list.