Practical C++ Programming [NOOK Book]

Overview

C++ is a powerful, highly flexible, and adaptable programming language that allows software engineers to organize and process information quickly and effectively. But this high-level language is relatively difficult to master, even if you already know the C programming language.The 2nd edition of Practical C++ Programming is a complete introduction to the C++ language for programmers who are learning C++. Reflecting the latest changes to the C++ standard, this 2nd edition takes a useful down-to-earth approach, ...

See more details below
Practical C++ Programming

Available on NOOK devices and apps  
  • NOOK Devices
  • NOOK HD/HD+ Tablet
  • NOOK
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac
  • NOOK Study

Want a NOOK? Explore Now

NOOK Book (eBook)
$24.99
BN.com price
(Save 41%)$42.99 List Price

Overview

C++ is a powerful, highly flexible, and adaptable programming language that allows software engineers to organize and process information quickly and effectively. But this high-level language is relatively difficult to master, even if you already know the C programming language.The 2nd edition of Practical C++ Programming is a complete introduction to the C++ language for programmers who are learning C++. Reflecting the latest changes to the C++ standard, this 2nd edition takes a useful down-to-earth approach, placing a strong emphasis on how to design clean, elegant code.In short, to-the-point chapters, all aspects of programming are covered including style, software engineering, programming design, object-oriented design, and debugging. It also covers common mistakes and how to find (and avoid) them. End of chapter exercises help you ensure you've mastered the material.Practical C++ Programming thoroughly covers:

  • C++ Syntax
  • Coding standards and style
  • Creation and use of object classes
  • Templates
  • Debugging and optimization
  • Use of the C++ preprocessor
  • File input/output
Steve Oualline's clear, easy-going writing style and hands-on approach to learning make Practical C++ Programming a nearly painless way to master this complex but powerful programming language.


C++ primer, practical style guide and a debugger "how-to" all in one. Many examples instruct by having you debug programs. For those with no programming experience, C programmers moving to C++, and C++ programmers itching to fine-tune. Source code is available via ftp.

Read More Show Less

Editorial Reviews

From Barnes & Noble

Fatbrain Review

C++ primer, practical style guide and a debugger "how-to" all in one. Many examples instruct by having you debug programs. For those with no programming experience, C programmers moving to C++, and C++ programmers itching to fine-tune. Source code is available via ftp.
Read More Show Less

Product Details

  • ISBN-13: 9781449367169
  • Publisher: O'Reilly Media, Incorporated
  • Publication date: 12/13/2002
  • Sold by: Barnes & Noble
  • Format: eBook
  • Edition number: 2
  • Pages: 576
  • Sales rank: 933,197
  • File size: 5 MB

Meet the Author

Steve Oualline lives in Southern California, where he works as a software engineer for a major phone company. In his free time he is a real engineer on the Poway Midland Railroad. Steve has written almost a dozen books on programming and Linux software. His web site is oualline.com .

Read More Show Less

Read an Excerpt


Chapter 7: The Programming Process

Maintenance

Good programmers put their programs through a long and rigorous testing process before releasing it to the outside world. Then the first user tries the program and almost immediately finds a bug. This starts the maintenance phase. Bugs are fixed, the program is tested (to make sure the fixes didn't break anything), and the program is released again.

Revisions

Although the program is officially finished, you are not finished with it. After it is in use for a few months, someone will come to us and ask, "Can you add a modulus operator?" So you revise the specifications, add the change to the program, update the test plan, test the program, and release it again.

As time passes, more people will come to you with additional requests for changes. Soon the program has trig functions, linear regressions, statistics, binary arithmetic, and financial calculations. The design is based on the idea of one-character operators. Soon you find yourself running out of characters to use. At this point the program is doing work far beyond what it was initially designed to do. Sooner or later you reach the point where the program needs to be scrapped and a new one written from scratch. At this point you write a new Preliminary Specification and start the process over again.

Electronic Archaeology

Unfortunately, most programmers don't start a project at the design step. Instead they are immediately thrust into the maintenance or revision stage. This means the programmer is faced with the worst possible job: understanding and modifying someone else's code.

Contrary to popular belief, most C++ programs are not written by disorganized orangutans using Zen programming techniques and poorly commented in Esperanto. They just look that way. Electronic archeology is the art of digging through old code to discover amazing things (like how and why the code works).

Your computer can aid greatly in your search to discover the true meaning of someone else's code. Many tools are available for examining and formatting code. (Be careful with your selection of tools, however. Many C tools have yet to be upgraded for C++. See earlier sections on revisions.) Some of these tools include:

Cross-references. These programs have names like xref, cxref, and cross. System V UNIX has the utility cscope. They print out a list of variables and where the variables are used.

Program indenters. Programs such as cb and indent indent a program "correctly" (correct indentation is something defined by the tool maker).

Pretty printers. A pretty printer such as vgrind or cprint typesets source code for printing on a laser printer.

Call graphs. On System V UNIX the program cflow analyzes the structure of the program. On other systems there is a public domain utility, calls, that produces call graphs, showing who calls whom and who is called by whom.

Class browsers. A class browser allows you to display the class hierarchy so you can tell what components went into building the class as well as its structure. You'll learn what a class is in Chapter 13, Simple Classes.

Which tools should you use? Whichever ones work for you. Different programmers work in different ways. Some techniques for examining code are listed below. Choose the ones that work for you and use them.

Mark Up the Program

Take a printout of the program and make notes all over it. Use red or blue ink so you can tell the difference between the printout and the notes. Use a highlighter to emphasize important sections. These notes are useful; put them in the program as comments, and then make a new printout and start the process over again.

Use the Debugger The debugger is a great tool for understanding how something works. Most debuggers allow you to step through the program one line at a time, examining variables and discovering how things really work. Once you find out what the code does, make notes and put them in as comments.

Use the Text Editor as a Browser

One of the best tools for going through someone else's code is your text editor. Suppose you want to find out what the variable sc is used for. Use the search command to find the first place sc is used. Search again and find the second. Continue searching until you know what the variable does.

Suppose you find out that sc is used as a sequence counter. Since you're already in the editor, you can easily do a global search-and-replace to change the variable sc to sequence_counter. (Disaster warning: Make sure sequence_counter is not already defined as a variable before you make the change. Also make sure you do a word replacement or you'll find you replaced sc in places you didn't intend.) Comment the declaration and you're on your way to creating an understandable program.

Add Comments

Don't be afraid to put any information you have, no matter how little, into the comments. Some of the comments I've used include:

int state; // Controls some sort of state machine

int rmxy; // Something to do with color correction?

Finally, there is a catch-all comment:

int idn; // ???

which means, "I have no idea what this variable does." Even though the purpose is unknown, it is now marked as something that needs more work.

As you go through someone else's code adding comments and improving style, the structure will become clearer to you. By inserting notes (comments), you make the code better and easier to understand for future programmers.

Suppose you are confronted with the following program written by someone from the "The Terser the Better" school of programming. Your assignment is to figure out what this program does....

Read More Show Less

Table of Contents

Preface
1 What Is C++? 3
2 The Basics of Program Writing 9
3 Style 35
4 Basic Declarations and Expressions 49
5 Arrays, Qualifiers, and Reading Numbers 63
6 Decision and Control Statements 85
7 The Programming Process 97
8 More Control Statements 117
9 Variable Scope and Functions 129
10 The C++ Preprocessor 151
11 Bit Operations 167
12 Advanced Types 185
13 Simple Classes 197
14 More on Classes 217
15 Simple Pointers 227
16 File Input/Output 251
17 Debugging and Optimization 281
18 Operator Overloading 319
19 Floating Point 343
20 Advanced Pointers 355
21 Advanced Classes 381
22 Exceptions 403
23 Modular Programming 413
24 Templates 435
25 Portability Problems 447
26 Putting It All Together 455
27 From C to C++ 485
28 C++'s Dustier Corners 493
29 Programming Adages 499
Appendixes 505
App. A: ASCII Table 507
App. B: Ranges 511
App. C: Operator Precedence Rules 513
App. D: Computing sine Using a Power Series 515
Glossary 521
Index 543
Read More Show Less

Customer Reviews

Average Rating 2
( 4 )
Rating Distribution

5 Star

(1)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(3)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 4 Customer Reviews
  • Anonymous

    Posted July 3, 2012

    Very underwhelming

    I bought this book based on the quality of O'Reilly's Learning Python... In comparison this book is thoroughly awful. The author is overly verbose and yet somehow still manages to not really teach the reader anything at all. I don't have a recommended substitute but do not buy this book to learn c++.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted September 29, 2002

    O'Reilly's worst book ever?

    The aside from the above reveiw being completely true, the book is now (as of Sept 2002) completely and absolutely outdated. I was very disappointed with this book. The C++ language was not covered in any depth whatsoever. If not for it's outdatedness, it might be usefull for a student with absolutely no prior programming experience. I am surprised that O'Reilly still publishes this book due to the fact that the C++ technologies of today: STL, the 'bool' keyword, and more were standardized after this books writing. The book does not even mention them. To anyone wanting to learn modern C++ I highly recommend "The C++ Programming Language by Bjarne Stroustrup". Stroustrup is the creator of C++. I recommend strongly against purchasing this book and hope that O'Reilly fixes this blemish on their otherwise perfect reputation.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted January 11, 2000

    Lacks the quality expected from O'Reilly

    Although I have numerous other ORA books and enjoy them thoroughly, I must say that this book was not at all helpful. I feel that the primary problem with the text is that it did not give a good explanation about how to program in C++. Yes, it does explain how various features of the language work, but not how to implement them. The examples given were limited in scope and little explanation was given about how object oriented programming is really done. I would recommend to anyone planning to learn how to write C++ code and how to work with objects to read 'Thinking in C++' by Bruce Eckel rather than this book. I would also encourage the reader to visit Mr. Eckel¿s web site for more information about C++ programming.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted April 24, 2012

    No text was provided for this review.

Sort by: Showing all of 4 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)