Home > Store

C++ For C Programmers, Third Edition, 3rd Edition

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

C++ For C Programmers, Third Edition, 3rd Edition

Book

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

Description

  • Copyright 1999
  • Dimensions: 7" x 10"
  • Pages: 504
  • Edition: 3rd
  • Book
  • ISBN-10: 0-201-39519-3
  • ISBN-13: 978-0-201-39519-8

Extensively revised and updated, this proven book by noted C++/C expert Ira Pohl is written specifically for C programmers who are transitioning to C++. C++ For C Programmers, Third Edition takes an evolutionary teaching approach, using C as a starting point and C++ as a destination. This third edition reflects the new ANSI C++ Standard, and covers the latest language features--including detailed discussions of templates, STL, and exception handling. Each chapter contains a brief examination of Java that compares and contrasts it with C++, providing the C programmer with a more complete understanding of both C and C++ and their relationship to Java.

Highlights of C++ for C Programmers, Third Edition, include:

  • A smooth transition to C++ and object-oriented programming for programmers already familiar with C
  • Extensive exercises and frequent language comparisons to teach concepts quickly and to introduce the language's powerful object-oriented features
  • Pohl's trademark "dissection" code presentation technique, which illustrates the underlying structure of programs and makes design tradeoffs understandable


0201395193B04062001

Downloads

Source Code

Source Code

Programs.zip

Programs.tar

Programs.sit

Sample Content

Table of Contents

(Each chapter concludes with a Summary, Review Questions and Exercises.)

Preface.


1. An Overview of C++ and Object-Oriented Programming.

Object-Oriented Programming.

Why Learn C++?

C as a Starting Point.

Classes and Abstract Data Types.

Constructors and Destructors.

Overloading.

Dissection of the Operator+() Function.

Inheritance.

Moving from C++ to Java.

Dissection of the improved Program.

Benefits of Object-Oriented Programming.

Pragmatics.



2. Native Types and Statements.

Program Elements.

Comments.

Keywords.

Identifiers.

Literals.

Operators and Punctuators.

Input/Output.

Program Structure.

Simple Types.

Initialization.

The Traditional Conversions.

Enumeration Types.

Typedef Declarations.

Expressions.

Statements.

Assignment and Expressions.

The Compound Statement.

The if and if-else Statements.

The while Statement.

The for Statement.

The do Statement.

The break and continue Statements.

The switch Statement.

The goto Statement.

Pragmatics.

Moving from C++ to Java.

Dissection of the Moon Program.



3. Functions, Pointers, and Arrays.

Functions.

Function Invocation.

Function Definition.

The return Statement.

Function Prototypes.

Recursion.

Default Arguments.

Functions as Arguments.

Overloading Functions.

Inlining.

Scope and Storage Class.

The Storage Class auto.

The Storage Class extern.

The Storage Class register.

The Storage Class static.

Linkage Mysteries.

Namespaces.

Pointer Types.

Addressing and Dereferencing.

Pointer-Based Call-by-Reference.

Dissection of the order() Function.

Reference Declarations and Call-by-Reference.

The Uses of void.

Arrays and Pointers.

Subscripting.

Initialization.

The Relationship Between Arrays and Pointers.

Passing Arrays to Functions.

The char String: A Kernel Language ADT.

Multidimensional Arrays.

Assertions and Program Correctness.

Free-Store Operators new and delete.

Dissection of the dynarray Program.

Pragmatics.

Vector Instead of Array.

String Instead of char.

Moving from C++ to Java.

Dissection of the Sum Array Program.



4. Classes.

The Aggregate Type Struct and class.

Structure Pointer Operator.

Member Functions.

Access: Private and Public.

Classes.

Class Scope.

Scope Resolution Operator.

Nested Classes.

An Example: Flushing.

static and const Members.

Dissection of the salary Program.

Mutable Members.

The this Pointer.

Unions.

Bit Fields.

A Container Class Example: ch_stack.

Pragmatics.

Moving from C++ to Java.



5. Constructors and Destructors.

Classes with Constructors.

The Default Constructor.

Constructor Initializer.

Constructors as Conversions.

Improving the <CODE>point</CODE> Class.

Constructing a Dynamically Sized Stack.

The Copy Constructor.

Classes with Destructors.

An Example: Dynamically Allocated Strings.

Dissection of the my_string Class.

The Class dbl_vect.

dbl_vect as a Linear Vector Type.

Members That Are Class Types.

Example: A Singly Linked List.

Dissection of the print() and release() Functions.

Two-Dimensional Arrays.

Polynomials as a Linked List.

Strings Using Reference Semantics.

No Constructor, Copy Constructor, and Other Mysteries.

Destructor Details.

Pragmatics.

Moving from C++ to Java.



6. Operator Overloading and Conversions.

ADT Conversions.

Overloading and Function Selection.

Dissection of the rational Program.

Friend Functions.

Overloading Operators.

Unary Operator Overloading.

Binary Operator Overloading.

Overloading Assignment and Subscripting Operators.

Dissection of dbl_vect::operator=() Function.

Polynomial: Type and Language Expectations.

Overloading I/O Operators << and >>.

Overloading Operator () for Indexing.

Dissection of the Class matrix.

Overloading the Pointer Operator ->.

Overloading new and delete.

Pragmatics.

Signature Matching.

Moving from C++ to Java.



7. Templates, Generic Programming, and STL.

Template Class stack.

Function Templates.

Signature Matching and Overloading.

Class Templates.

Friends.

Static Members.

Class Template Arguments.

Default Template Arguments.

Member Templates.

Parameterizing the Class vector.

STL.

STL Example Code.

Containers.

Sequence Containers.

Dissection of the stl_vect Program.

Associative Containers.

Container Adapters.

Iterators.

The istream_iterator and ostream_iterator.

Iterator Adapters.

Algorithms.

Sorting Algorithms.

Nonmutating Sequence Algorithms.

Mutating Sequence Algorithms.

Numerical Algorithms.

Numerical Integration Made Easy.

Pragmatics.

Moving from C++ to Java.



8. Inheritance.

A Derived Class.

Typing Conversions and Visibility.

Virtual Functions.

Abstract Base Classes.

Templates and Inheritance.

Multiple Inheritance.

Inheritance and Design.

Subtyping Form.

Code Reuse.

Runtime Type Identification.

Pragmatics.

Moving from C++ to Java.



9. Exceptions.

Using the assert Library.

C++ Exceptions.

Throwing Exceptions.

Rethrown Exceptions.

Exception Expressions.

Try Blocks.

Handlers.

Exception Specification.

Terminate() and Unexpected().

Example Exception Code.

Standard Exceptions and Their Uses.

Pragmatics.

Moving from C++ to Java.



10. OOP Using C++.

OOP Language Requirements.

ADTs: Encapsulation and Data Hiding.

Reuse and Inheritance.

Polymorphism.

OOP: The Dominant Programming Methodology.

Designing with OOP in Mind.

Class-Responsibility-Collaborator.

Design Patterns.

Moving from C++ to Java.



Appendix A: ASCII Character Codes.


Appendix B: Operator Precedence and Associativity.


Appendix C: Language Guide.

Program Structure.

Lexical Elements.

Comments.

Identifiers.

Keywords.

Constants.

Declarations and Scope Rules.

Namespaces.

Linkage Rules.

Types.

Conversion Rules and Casts.

Expressions and Operators.

sizeof Expressions.

Autoincrement and Autodecrement Expressions.

Arithmetic Expressions.

Relational, Equality, and Logical Expressions.

Assignment Expressions.

Comma Expressions.

Conditional Expressions.

Bit-Manipulation Expressions.

Address and Indirection Expressions.

new and delete Expressions.

Other Expressions.

Statements.

Expression Statements.

The Compound Statement.

The if and if-else Statements.

The while Statement.

The for Statement.

The do Statement.

The Break and Continue Statements.

The switch Statement.

The go to Statement.

The return Statement.

The Declaration Statement.

Functions.

Prototypes.

Call-by-Reference.

Inline Functions.

Default Arguments.

Overloading.

Type-Safe Linkage for Functions.

Classes.

Constructors and Destructors.

Member Functions.

Friend Functions.

The this Pointer.

Operator Overloading.

static and const Member Functions.

Mutable.

Inheritance.

Multiple Inheritance.

Constructor Invocation.

Abstract Base Classes.

Pointer to Class Member.

Runtime Type Identification.

Virtual Functions.

Templates.

Template Parameters.

Function Template.

Friends.

Static Members.

Specialization.

Exceptions.

Throwing Exceptions.

Try Blocks.

Handlers.

Exception Specification.

Terminate() and Unexpected().

Standard Library Exceptions.

Caution and Compatibility.

Nested Class Declarations.

Type Compatibilities.

Miscellaneous.

New Features in C++.



Appendix D: Input/Output.

The Output Class ostream.

Formatted Output and iomanip.

User-Defined Types: Output.

The Input Class istream.

Files.

Using Strings as Streams.

The Functions and Macros in ctype.

Using Stream States.

Mixing I/O Libraries.



Appendix E: STL and String Libraries.

Containers.

Sequence Containers.

Associative Containers.

Container Adapters.

Iterators.

Iterator Categories.

Iterator Adapters.

Algorithms.

Sorting Algorithms.

Nonmutating Sequence Algorithms.

Mutating Sequence Algorithms.

Numerical Algorithms.

Functions.

Function Adapters.

Allocators.

String Library.

Constructors.

Member Functions.

Global Operators.



References.


Index. 0201395193T04062001

Preface

The book uses an evolutionary teaching process, with C as a starting point and C++ as a destination. It can also be used by those already familiar with other similar programming languages, such as Pascal, PL/1, or BASIC. The reader can stop and use the language facilities at various points in the text.

This book will get the C programmer up and running in C++ in the shortest possible time. The teaching-by-equivalency method used enables the C programmer to immediately convert existing code to C++. Working code is emphasized. A program particularly illustrative of the chapter's themes is analyzed by dissection, which is similar to a structured walk-through of the code. Dissection explains to the reader newly encountered programming elements and idioms.

C is a general-purpose programming language that was originally designed by Dennis Ritchie of Bell Laboratories and implemented there on a PDP-11 in 1972. C was first used as the systems language for the UNIX operating system. Ken Thompson, the developer of UNIX, had been using both an assembler and a language named B to produce initial versions of UNIX in 1970.

C++, invented at Bell Labs by Bjarne Stroustrup in the mid-1980s, is a powerful modern successor language to C. C++ adds to C the concept of class, a mechanism for providing user-defined types, also called abstract data types. C++ supports object-oriented programming by these means and by providing inheritance and runtime type binding. C++ is increasingly the choice of scientists and engineers in developing scientific software.

This book, intended for use in a first course in C++ programming, can be used as a supplementary text in an advanced programming, data structures, software methodology, comparative language, or other course in which the instructor wants C++ to be the language of choice. Each chapter presents a number of carefully explained programs.

All of the major pieces of code were tested. A consistent and proper coding style is adopted from the beginning and is one chosen by professionals in the C++ community. The code is available at the Addison Wesley Longman Web site (www.awl.com/cseng/titles/0-201-39519-3/).

For the programmer who wants C experience, this book could be used in conjunction with A Book on C, 4th ed., by Al Kelley and Ira Pohl (Addison-Wesley, 1998). As a package, the two books offer a unique, integrated treatment of the C and C++ programming languages and their use.

This book incorporates a number of important features.

  • An evolutionary approach. The C programmer can immediately benefit from programming in C++. Chapter 1, "An Overview of C++ and Object-Oriented Programming," provides an introduction to the use of C++ as an object-oriented programming language. Chapter 2, "Native Types and Statements," reviews the kernel language, which is mostly C with some improvements. Chapter 3, "Functions, Pointers, and Arrays," continues with similarities between functions and complex data types. The middle chapters show how to use classes, which are the basis for abstract data types and object-oriented programming (OOP). The later chapters give advanced details of the use of inheritance, templates, and exceptions. At any point in the text, the programmer can stop and use the new material.

  • Teaching by example. The book is a tutorial that stresses examples of working code. Right from the start, the student is introduced to full working programs. An interactive environment is assumed. Exercises are integrated with the examples to encourage experimentation. Excessive detail is avoided in explaining the larger elements of writing working code. Each chapter has several important example programs. Major elements of these programs are explained by dissection.

  • Data structures in C++. The text emphasizes many of the standard data structures from computer science. Stacks, safe arrays, dynamically allocated multidimensional arrays, lists, trees, and strings are all implemented. Exercises extend the student's understanding of how to implement and use these structures. Implementation is consistent with an abstract data type approach to software.

  • Object-oriented programming. The reader is led gradually to the object-oriented style. Chapter 1, "An Overview of C++ and Object-Oriented Programming," discusses how the C programmer can benefit in important ways from a switch to C++ and object-oriented programming. Object-oriented concepts are defined, and the way in which these concepts are supported by C++ is introduced. Chapter 4, "Classes," introduces classes, which are the basic mechanism for producing modular programs and implementing abstract data types. Class variables are the objects being manipulated. Chapter 8, "Inheritance," develops inheritance and virtual functions, two key elements in this paradigm. Chapter 10, "OOP Using C++," discusses OOP programming philosophy. This book develops in the programmer an appreciation of this point of view.

  • C equivalence. Where appropriate, C++ code is given with equivalent C code. This gives the experienced C programmer immediate access to idiomatic C++ code.

  • New Java equivalence. At the end of each chapter is a discussion of how the C++ programmer can very naturally and easily begin programming in Java, a language of interest for work on the Internet. The Java programming language borrows ideas from C++ and is designed to run in a machine- and system-independent manner. This makes it suitable for Internet work, such as writing applets for Web pages that are used by browsers. Because Java is an extension of C++, it is readily learned by the C++ programmer.

  • ANSI C++ language and iostream. For an existing, widely used language, C++ continues to change at a rapid pace. This book is based on the most recent standard: the ANSI C++ Committee language documents. A succinct informal language reference is provided in Appendix C, "Language Guide." Use of the iostream library is featured in Appendix D, "Input/Output," and STL is featured in Appendix E, "STL and String Libraries."

  • Standard template library (STL). STL is explained and used in Chapter 7, "Templates, Generic Programming, and STL," and in Appendix E, "STL and String Libraries." Many of the data structure examples foreshadow its explanation and use. There is a strong emphasis on the template mechanism required for STL and the iterator idiom that STL exploits.

  • Industry- and course-tested. This book is the basis of many on-site professional training courses given by the author, who has used its contents to train professionals and students in various forums since 1986. The various changes are course-tested and reflect the author's considerable teaching and consulting experience. The text is the basis for Web-based training in C++ available from www.digitalthink.com

  • Exercises. The exercises test and often advance the student's knowledge of the language. Many are intended to be done interactively while reading the text, encouraging self-paced instruction.

  • Web site. The examples both within the book and at Addison-Wesley's Web site are intended to exhibit good programming style. The Addison-Wesley Web site for this book contains the programs in the book, as well as adjunct programs that illustrate points made in the book or flesh out short pieces of programs. The programs available at the Web site are introduced by their .cpp or .h names and can be obtained by referencing www.awl.com/cseng/titles/0-201-39519-3/

My special thanks go to my wife, Debra Dolsberry, who encouraged me throughout this project. She acted as book designer and technical editor for this edition. She developed appropriate formats and style sheets in FrameMaker 5.5 and guided the transition process from my other books on C++. She also implemented and tested all major pieces of code.

This book was developed with the support of my editor, J. Carter Shanklin, and editorial assistant, Angela Buenning.

--Ira Pohl
University of California, Santa Cruz



0201395193P04062001

Updates

Errata

Click below for Errata related to this title:
Errata

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