Home > Store

Applications Programming in C++

Register your product to gain access to bonus material or receive a coupon.

Applications Programming in C++

Book

  • Sorry, this book is no longer in print.
Not for Sale

About

Features

  • Up-to-date coverage of C++, including sections on new-style headers, new-style casts, type bool, namespaces, namespace std, and STL.
  • An entire chapter on STL (standard template library), with detailed discussions on such features as containers, iterators, algorithms, function objects, and container and function object adaptors.
  • Topics grouped according to their use and their relationships to one another. This organization enables readers to write simple but useful program immediately.
  • Starts students off with a practical introductory chapter to computer systems and program development.
  • Builds skills and fortifies retention.
  • Groups topics according to their use and their relationships to one another.
  • Alerts students to common mistakes and misconceptions with:
    • Lists of common programming errors.

    • C++ Postscript sections at the end of each chapter that discuss less-used parts of the language and give additional technical details about certain parts of the language.

  • Contains five useful appendices that cover such areas as the ASCII table, a list of some of the most useful C++ functions and class methods, and more.

Description

  • Copyright 1999
  • Dimensions: 7" x 9-1/4"
  • Pages: 744
  • Edition: 1st
  • Book
  • ISBN-10: 0-13-748963-3
  • ISBN-13: 978-0-13-748963-3

Exceptionally organized and beautifully illustrated, this state-of-the-art guide to C++ programming is a must-have for anyone who needs to learn the language. Exploring C++ programming's most useful aspects (as well as some of its more specialized parts), it focuses on using the language to write practical programs based on sound design techniques. KEY TOPICS:Presents the must up-to-date coverage of C++ available - including a full section on STL (standard template library) - and offers many well-constructed examples, useful self-test exercises, beautifully fashioned sample applications, interesting and applicable programming exercises, lists of common programming errors, C++ Postscript sections that explain esoteric and less-used parts of the language, stunning illustrations, and up-to-date features. Includes a supplemental IBM-format program disk; a companion website contains the sourcecode, header files, and data files found on the disk as well as transparencies and an errata list.

Sample Content

Table of Contents

(NOTE: Most chapters conclude with a C++ Postscript, Common Programming Errors, and Programming Exercises.)

0. Computer Systems and Program Development.

Algorithms. Computer Systems. Internal Representations. Programming Languages. Problem Solving and Program Development. Why C++?



1. Introduction to Data Types and Operators.

A First C++ Program. The int Data Type. Identifiers. Sample Application: Conversion of Lengths. Other Integer Data Types. Floating-Point Data Types. Arithmetic Operators. Sample Application: A Math Puzzle. Relational and Logical Operators.



2. Control Flow.

The tt if-tt else Statement. Sample Application: Computing Taxes. The while Statement. Sample Application: Computing Taxes Revisited. Files. The do while Statement. The for Statement. Assignment, Increment, and Decrement Operators. Sample Application: Statistical Measures. The break, continue, and switch Statements. Sample Application: Generating Prime Numbers. Promotions and Casts. Formatting.



3. Functions.

Introduction. Scope. Call by Value. Sample Application: The Monty Hall Problem. Call by Reference. Sample Application: Printing a Calendar. Overloading Functions. Recursion.



4. Arrays.

Why Arrays? The Index Operator. Arrays and Pointers. Sample Application: Totaling Votes. Character Strings. Arrays and Functions. String-Handling Functions. Sample Application: Merging Files. Multidimensional Arrays. Sample Application: Maintaining an Address Book.



5. Classes.

Object-Oriented and Procedural Programming. Classes and Objects. Sample Application: A Clock Class. Sample Application: A Time Stamp Class. Constructors and the Destructor. Sample Application: A Task Class. Class Data Members and Methods. Using Class Libraries. Pointers to Objects and the Indirect Selection Operator.



6. Inheritance.

Introduction. Basic Concepts and Syntax. Sample Application: Tracking Films. protected Members. Constructors and Destructors Under Inheritance. Sample Application: A Sequence Hierarchy.



7. Polymorphism.

Run-Time versus Compile-Time Binding in C++. Sample Application: Tracking Films Revisited. Name Overloading, Name Overriding, and Name Hiding. Abstract Base Classes.



8. Operator Overloading.

Basic Operator Overloading. Sample Application: A Complex Number Class. Operator Overloading Using Top-Level Functions. friend Functions. Overloading the Input and Output Operators. Overloading Some Special Operators. Sample Application: An Associative Array.



9. Storage.

Compile-Time and Run-Time Storage. Storage Classes for Variables. Pointers and Dynamic Storage. Sample Application: Sorting and Searching. Classes with Pointers as Data Members.



10. Templates and the Standard Template Library.

Template Basics. Sample Application: A Template Stack Class. Namespaces. The Standard Template Library. Sample Application: Stock Performance Reports.



A. ASCII Table.


B. The Preprocessor.


C. Selected C++ Functions and Methods.


D. Run-Time Type Identification.


E. Exception Handling.


Hints and Solutions to Odd-Numbered Exercises.


Index.

Preface

Preface
Applications Programming in C++ is based on C++ courses given by the authors at DePaul University over the last several years. We assume no prior knowledge of C++, but we do assume programming experience in some high-level language. We provide Chapter 0 as background for those with modest programming experience. More advanced users can begin with Chapter 1. The book can be used for a one-term course in applications programming in C++ or for self-study.

The book and its supplements---an Instructor's Guide and a World Wide Web site---provide a comprehensive support system to help the reader master C++. The book includes numerous examples, exercises, sample applications, programming exercises, lists of common programming errors, and illustrations.

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. Because this is an introductory book, 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 end-of-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++.
This book includes the following features:

  • Examples and exercises that cover a wide range of applications.
  • Motivating real-world applications.
  • A broad variety of programming exercises. The book contains over 160 programming exercises.
  • Sections on common programming errors.
  • Discussion of standard C++ functions and methods.
  • Exercises at the ends of sections so that readers can check their mastery of the sections.
    The book contains nearly 600 such exercises. Answers to the odd-numbered section exercises are given in the back of the book, and answers to the even-numbered section exercises are given in the Instructor's Guide.
  • Illustrations to facilitate the learning process.
  • The latest changes to the C++ language including new-style headers, new-style casts, type, namespaces, and the namespace.
  • A discussion of algorithms (Section 0.1).
  • Coverage of computer systems (Section 0.2).
  • An overview of programming languages (Section 0.4).
  • A discussion of program development including program specification, algorithm design, coding, and testing (Section 0.5).
  • Problem-solving strategies (Section 0.5).
  • Early coverage of files (Section 2.5).
  • A thorough discussion of recursion (Section 3.8).
  • Coverage of STL (the Standard Template Library) (Chapter 10).
  • A number of appendices.
  • Topics grouped according to their use and their relationships to one another. This organization enables readers to write simple but useful programs immediately and to skip or postpone some of the less often used and more esoteric parts of the language.
  • Understandable code. We have opted for clarity rather than subterfuges based on obscure C++ features.

C++: A Hybrid Language
C++ is essentially C with extensions to support object-oriented programming. Because C supports traditional, procedural programming, C++ is a hybrid language; it supports both procedural and object-oriented programming. It is a challenge to teach both procedural and object-oriented programming in the same course and to develop pedagogical strategies to address both programming paradigms. This book reflects our belief, based on our experience teaching C++, that some procedural programming is necessary before moving on to the object-oriented parts of C++. Thus we first cover basic control structures (e.g., loops, if statements), data types, operators, arrays, and functions. Once the basics of C++ as a procedural language have been covered, we introduce classes, inheritance, and polymorphism---the key concepts in object-oriented programming. We then turn to operator overloading, storage, templates, and other C++ features. This approach is justified because:
  • It is pedagogically sound to begin with less abstract topics (e.g., basic control structures) before moving up to more abstract topics (e.g., classes and inheritance).
  • All but the most trivial classes need basic control structures, data types, operators, arrays, and functions. Even if the programming paradigm is "object-oriented,"' implementation of classes requires basic control structures, data types, operators, arrays, and functions.

Organization of the Book
Chapter 0 serves as an introduction to computer systems and program development. (This chapter can be skipped if this material is already known.) We begin in Section 0.1 by discussing algorithms. Section 0.2 presents an overview of computer systems including hardware (main memory, CPU, etc.) and software (text editors, compilers, etc.). Internal representations of integers, floating-point numbers, characters, and instructions are discussed in Section 0.3. Section 0.4 continues with a discussion of programming languages (assembly languages and high-level languages). Section 0.5 summarizes the phases of program development: program specification, algorithm design, coding, and testing. In addition, several problem-solving strategies are given in Section 0.5. A discussion of the C++ language (Section 0.6) concludes Chapter 0.
Chapters 1 through 4 are devoted to the basics of C++ as a procedural language. In Chapter 1 we discuss integer and floating-point data types; identifiers; and arithmetic, relational, and logical operators. After Chapter~1, readers can immediately begin writing simple, but useful, programs.
In Chapter 2, we discuss the if-else statement; while, do while, and for loops; files; the assignment, increment, and decrement operators; the break, continue, and switch statements; promotions and casts; and basic formatting. Because C++ programs compiled under Windows are best used with disk input and output files, we treat files early.
Functions and program structure are discussed in Chapter 3. Parameters and call by value are covered in Sections 3.1 through 3.3. Call by reference is the topic of Section 3.5. Function overloading is introduced in Section 3.7. Recursion is the topic of Section 3.8. Sections 3.4 and 3.6 are devoted to sample applications.
Chapter 4 is devoted to arrays. Pointers and character strings are introduced to underscore their connection with arrays.
After covering the basics of C++ as a procedural language, we introduce the object-oriented features: classes, inheritance, and polymorphism. We cover class basics in Chapter 5: classes and objects, data members and methods, constructors and the destructor, defining classes and using them in programs, and using existing class libraries.
Chapter 6 introduces inheritance, including protected members, and constructors and the destructor under inheritance.
Polymorphism (run-time binding) is the topic of Chapter 7. Also, in this chapter, we discuss the difference between run-time binding and features that resemble it. This chapter also explains how an abstract base class can be used to specify an interface and emphasizes the importance of interfaces in the object-oriented model.
Chapter 8 considers operator overloading for classes, including overloading operators as either methods or top-level functions. This chapter abounds with examples to show how operators may be overloaded to advantage.
Storage is the topic of Chapter 9. Compile-time and run-time storage are discussed in detail, as are the main C++ storage classes: auto, static, and extern.
Chapter 10 shows how C++ supports generic functions through templates. This chapter also introduces STL (Standard Template Library) and offers short programs to illustrate STL containers, iterators, algorithms, and function objects.
In each of Chapters 1--10, 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 the problem in C++. Most of these sections conclude with an extended discussion. In some of the examples, these sections include a line-by-line discussion of the C++ program.
The sample applications include the following:
  • Statistics (Section 2.9).
  • Simulation (the Monty Hall problem) (Section 3.4).
  • Counting votes (Section 4.4).
  • A task class (Section 5.6).
  • Tracking films (Sections 6.3 and 7.2).
  • An associative array class (Section 8.7).
  • Sorting and searching (Section 9.4).
  • A template stack class (Section 10.2).
  • Stock performance reports using STL (Section 10.5).
The C++ Postscript sections discuss less-used parts of the language and give additional technical details about certain parts of the language.
The Common Programming Errors sections highlight those aspects of the language that are easily misunderstood.

The book
contains over 160 programming exercises drawn from a wide variety of applications.
Examples
The book contains over 350 numbered examples, which clarify particular facets of C++ for the reader and show the purpose of various C++ features. A box \outlinediamond\ marks the end of each example.

Exercises
The book contains nearly 600 section review exercises, the answers to which are true or false, 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.
Class testing this book 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:

  • Vote fraud (Programming Exercise 2.12)
  • Weight lifting (Programming Exercise 2.13)
  • Chaos (Programming Exercise 2.14)
  • Simulation (Programming Exercises 3.15 and 5.14)
  • Game of {\it Life} (Programming Exercise 4.18)
  • Digital images (Programming Exercise 4.20)
  • Data structures (Programming Exercises 5.8, 5.9, and 9.2 through 9.7)
  • Databases (Programming Exercise 5.15)
  • Scheduling (Programming Exercises 5.18 and 10.14)
  • Windows environments (Programming Exercise 7.8)
  • Dating services (Programming Exercise 7.10)
  • Software engineering (Programming Exercise 9.1)
  • World Wide Web (Programming Exercise 10.12)
Not every reader will be interested in all of these applications; however, we think that it is important to show the variety of problems that C++ can address.

Appendices
Five appendices are provided for reference. Appendix A contains the ASCII table. Appendix B explains the C++ preprocessor. Appendix C contains a list of some of the most useful C++ functions and class methods. We describe the parameters and return values for each, the header file to include, and what the function or method does. Appendix D covers run-time type identification (RTTI), and Appendix E covers exception handling.

Recent Language Changes
We have incorporated the latest changes to the C++ language including:

  • The logical type.
  • New-style headers.
  • Namespaces and the namespace.
  • New-style casts.
  • STL (Standard Template Library).
  • Exception handling.
  • Run-time type identification.
  • Namespaces and the namespace.
  • The operator.

We use these new features throughout the book, but for those readers using older compilers, we also explain how to convert to the old-style C++.
Before the logical type was introduced, integer types were used for false (zero) and true (nonzero).
New-style headers drop the extension and prefix to the header files acquired from C. For example, the old C++ header file becomes, and the C header file becomes. Standard features furnished by these header files are now grouped under the name ( standard). The technical term for a region in which such features are grouped is namespace.

Acknowledgments
We thank the following reviewers: Ed Angel, University of New Mexico; Karen Bernstein, DePaul University; Ralph Ewton, University of Texas at El Paso; Mike Gearen, Punahou High School; Jeanine Ingber, University of New Mexico; and Bina Ramamurthy, SUNY at Buffalo. We are grateful to our friendly copy editor, Patricia Johnsonbaugh, for smoothing our prose and for deleting words and statements we drafted but should not have.
Our student, Wen Tao Liu, helped us check most of the major code segments.
We are indebted to the School of Computer Science, Telecommunications and Information Systems at DePaul University and its dean, Helmut Epp, for providing time and encouragement for the development of this book.
We received consistent support from the people at Prentice Hall. Special thanks go to Alan Apt, publisher, and Laura Steele, acquisitions editor.
R.J. M.K.

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020