C++ Cookbook

( 2 )

Overview

Despite its highly adaptable and flexible nature, C++ is also one of the more complex programming languages to learn. Once mastered, however, it can help you organize and process information with amazing efficiency and quickness.

The C++ Cookbook will make your path to mastery much shorter. This practical, problem-solving guide is ideal if you're an engineer, programmer, or researcher writing an application for one of the legions of platforms on which C++ runs. The algorithms ...

See more details below
Other sellers (Paperback)
  • All (17) from $4.56   
  • New (11) from $27.71   
  • Used (6) from $4.56   
C++ Cookbook

Available on NOOK devices and apps  
  • NOOK Devices
  • Samsung Galaxy Tab 4 NOOK 7.0
  • Samsung Galaxy Tab 4 NOOK 10.1
  • NOOK HD Tablet
  • NOOK HD+ Tablet
  • NOOK eReaders
  • 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

Want a NOOK? Explore Now

NOOK Book (eBook)
$22.99
BN.com price
(Save 42%)$39.99 List Price

Overview

Despite its highly adaptable and flexible nature, C++ is also one of the more complex programming languages to learn. Once mastered, however, it can help you organize and process information with amazing efficiency and quickness.

The C++ Cookbook will make your path to mastery much shorter. This practical, problem-solving guide is ideal if you're an engineer, programmer, or researcher writing an application for one of the legions of platforms on which C++ runs. The algorithms provided in C++ Cookbook will jump-start your development by giving you some basic building blocks that you don't have to develop on your own.

Less a tutorial than a problem-solver, the book addresses many of the most common problems you're likely encounter—whether you've been programming in C++ for years or you're relatively new to the language. Here are just some of the time-consuming tasks this book contains practical solutions for:

  • Reading the contents of a directory
  • Creating a singleton class
  • Date and time parsing/arithmetic
  • String and text manipulation
  • Working with files
  • Parsing XML
  • Using the standard containers

Typical of O'Reilly's "Cookbook" series, C++ Cookbook is written in a straightforward format, featuring recipes that contain problem statements and code solutions, and apply not to hypothetical situations, but those that you're likely to encounter. A detailed explanation then follows each recipe in order to show you how and why the solution works. This question-solution-discussion format is a proven teaching method, as any fan of the "Cookbook" series can attest to. This book will move quickly to the top of your list of essential C++ references.

Designed for the way many developers work, this practical problem-solving guide balances the need for rapid development with a trusted source of information.

Read More Show Less

Product Details

  • ISBN-13: 9780596007614
  • Publisher: O'Reilly Media, Incorporated
  • Publication date: 10/18/2005
  • Series: Cookbooks (O'Reilly) Series
  • Edition number: 1
  • Pages: 594
  • Sales rank: 892,305
  • Product dimensions: 9.10 (w) x 7.00 (h) x 1.30 (d)

Meet the Author

Ryan Stephens is a software engineer, writer, and student living in Tempe, AZ. He enjoys programming in virtually any language, especially C++. His interests include the fields of information retrieval and data mining, and pretty much anything that has to do with algorithms and large data sets. When he's not working, writing, or programming, he plays with his kids, works on his house, or goes cycling.

Christopher Diggins is a freelance software developer and writer who has been programming computers since he was "haut comme trois pommes". Christopher writes regularly for the C++ Users Journal, and is the designer of the Heron programming lanugage.

Jonathan Turkanis is the author of the Boost Iostreams library and several other open source C++ libraries covering areas including smart pointers, runtime reflection, component architectures and aspect-oriented programming. He is a Ph.D. candidate in mathematical logic at the University of California at Berkeley.

Jeff Cogswell has been programming in several languages for many years. His background was previously in telecom, writing software for such strange things as network management protocols. Lately, however, his work has focused more on web development. After spending a few years in both Florida and California, Jeff now lives in Michigan. He's holding out for some warmer weather.

Read More Show Less

Table of Contents

Preface;
About the Examples;
Conventions Used in This Book;
Using Code Examples;
Comments and Questions;
Safari Enabled;
Acknowledgments;
Chapter 1: Building C++ Applications;
1.1 Introduction to Building;
1.1 Obtaining and Installing GCC;
1.2 Building a Simple "Hello, World" Application from the Command Line;
1.3 Building a Static Library from the Command Line;
1.4 Building a Dynamic Library from the Command Line;
1.5 Building a Complex Application from the Command Line;
1.6 Installing Boost.Build;
1.7 Building a Simple "Hello, World" Application Using Boost.Build;
1.8 Building a Static Library Using Boost.Build;
1.9 Building a Dynamic Library Using Boost.Build;
1.10 Building a Complex application Using Boost.Build;
1.11 Building a Static Library with an IDE;
1.12 Building a Dynamic Library with an IDE;
1.13 Building a Complex Application with an IDE;
1.14 Obtaining GNU make;
1.15 Building A Simple "Hello, World" Application with GNU make;
1.16 Building a Static Library with GNU Make;
1.17 Building a Dynamic Library with GNU Make;
1.18 Building a Complex Application with GNU make;
1.19 Defining a Macro;
1.20 Specifying a Command-Line Option from Your IDE;
1.21 Producing a Debug Build;
1.22 Producing a Release Build;
1.23 Specifying a Runtime Library Variant;
1.24 Enforcing Strict Conformance to the C++ Standard;
1.25 Causing a Source File to Be Linked Automatically Against a Specified Library;
1.26 Using Exported Templates;
Chapter 2: Code Organization;
2.1 Introduction;
2.1 Making Sure a Header File Gets Included Only Once;
2.2 Ensuring You Have Only One Instance of a Variable Across Multiple Source Files;
2.3 Reducing #includes with Forward Class Declarations;
2.4 Preventing Name Collisions with Namespaces;
2.5 Including an Inline File;
Chapter 3: Numbers;
3.1 Introduction;
3.1 Converting a String to a Numeric Type;
3.2 Converting Numbers to Strings;
3.3 Testing Whether a String Contains a Valid Number;
3.4 Comparing Floating-Point Numbers with Bounded Accuracy;
3.5 Parsing a String Containing a Number in Scientific Notation;
3.6 Converting Between Numeric Types;
3.7 Getting the Minimum and Maximum Values for a Numeric Type;
Chapter 4: Strings and Text;
4.1 Introduction;
4.1 Padding a String;
4.2 Trimming a String;
4.3 Storing Strings in a Sequence;
4.4 Getting the Length of a String;
4.5 Reversing a String;
4.6 Splitting a String;
4.7 Tokenizing a String;
4.8 Joining a Sequence of Strings;
4.9 Finding Things in Strings;
4.10 Finding the nth Instance of a Substring;
4.11 Removing a Substring from a String;
4.12 Converting a String to Lower- or Uppercase;
4.13 Doing a Case-Insensitive String Comparison;
4.14 Doing a Case-Insensitive String Search;
4.15 Converting Between Tabs and Spaces in a Text File;
4.16 Wrapping Lines in a Text File;
4.17 Counting the Number of Characters, Words, and Lines in a Text File;
4.18 Counting Instances of Each Word in a Text File;
4.19 Add Margins to a Text File;
4.20 Justify a Text File;
4.21 Squeeze Whitespace to Single Spaces in a Text File;
4.22 Autocorrect Text as a Buffer Changes;
4.23 Reading a Comma-Separated Text File;
4.24 Using Regular Expressions to Split a String;
Chapter 5: Dates and Times;
5.1 Introduction;
5.1 Obtaining the Current Date and Time;
5.2 Formatting a Date/Time as a String;
5.3 Performing Date and Time Arithmetic;
5.4 Converting Between Time Zones;
5.5 Determining a Day's Number Within a Given Year;
5.6 Defining Constrained Value Types;
Chapter 6: Managing Data with Containers;
6.1 Introduction;
6.1 Using vectors Instead of Arrays;
6.2 Using vectors Efficiently;
6.3 Copying a vector;
6.4 Storing Pointers in a vector;
6.5 Storing Objects in a list;
6.6 Mapping strings to Other Things;
6.7 Using Hashed Containers;
6.8 Storing Objects in Sorted Order;
6.9 Storing Containers in Containers;
Chapter 7: Algorithms;
7.1 Introduction;
7.1 Iterating Through a Container;
7.2 Removing Objects from a Container;
7.3 Randomly Shuffling Data;
7.4 Comparing Ranges;
7.5 Merging Data;
7.6 Sorting a Range;
7.7 Partitioning a Range;
7.8 Performing Set Operations on Sequences;
7.9 Transforming Elements in a Sequence;
7.10 Writing Your Own Algorithm;
7.11 Printing a Range to a Stream;
Chapter 8: Classes;
8.1 Introduction;
8.1 Initializing Class Member Variables;
8.2 Using a Function to Create Objects (a.k.a. Factory Pattern);
8.3 Using Constructors and Destructors to Manage Resources (or RAII);
8.4 Automatically Adding New Class Instances to a Container;
8.5 Ensuring a Single Copy of a Member Variable;
8.6 Determining an Object's Type at Runtime;
8.7 Determining if One Object's Class Is a Subclass of Another;
8.8 Giving Each Instance of a Class a Unique Identifier;
8.9 Creating a Singleton Class;
8.10 Creating an Interface with an Abstract Base Class;
8.11 Writing a Class Template;
8.12 Writing a Member Function Template;
8.13 Overloading the Increment and Decrement Operators;
8.14 Overloading Arithmetic and Assignment Operators for Intuitive Class Behavior;
8.15 Calling a Superclass Virtual Function;
Chapter 9: Exceptions and Safety;
9.1 Introduction;
9.1 Creating an Exception Class;
9.2 Making a Constructor Exception-Safe;
9.3 Making an Initializer List Exception-Safe;
9.4 Making Member Functions Exception-Safe;
9.5 Safely Copying an Object;
Chapter 10: Streams and Files;
10.1 Introduction;
10.1 Lining Up Text Output;
10.2 Formatting Floating-Point Output;
10.3 Writing Your Own Stream Manipulators;
10.4 Making a Class Writable to a Stream;
10.5 Making a Class Readable from a Stream;
10.6 Getting Information About a File;
10.7 Copying a File;
10.8 Deleting or Renaming a File;
10.9 Creating a Temporary Filename and File;
10.10 Creating a Directory;
10.11 Removing a Directory;
10.12 Reading the Contents of a Directory;
10.13 Extracting a File Extension from a String;
10.14 Extracting a Filename from a Full Path;
10.15 Extracting a Path from a Full Path and Filename;
10.16 Replacing a File Extension;
10.17 Combining Two Paths into a Single Path;
Chapter 11: Science and Mathematics;
11.1 Introduction;
11.1 Computing the Number of Elements in a Container;
11.2 Finding the Greatest or Least Value in a Container;
11.3 Computing the Sum and Mean of Elements in a Container;
11.4 Filtering Values Outside a Given Range;
11.5 Computing Variance, Standard Deviation, and Other Statistical Functions;
11.6 Generating Random Numbers;
11.7 Initializing a Container with Random Numbers;
11.8 Representing a Dynamically Sized Numerical Vector;
11.9 Representing a Fixed-Size Numerical Vector;
11.10 Computing a Dot Product;
11.11 Computing the Norm of a Vector;
11.12 Computing the Distance Between Two Vectors;
11.13 Implementing a Stride Iterator;
11.14 Implementing a Dynamically Sized Matrix;
11.15 Implementing a Constant-Sized Matrix;
11.16 Multiplying Matricies;
11.17 Computing the Fast Fourier Transform;
11.18 Working with Polar Coordinates;
11.19 Performing Arithmetic on Bitsets;
11.20 Representing Large Fixed-Width Integers;
11.21 Implementing Fixed-Point Numbers;
Chapter 12: Multithreading;
12.1 Introduction;
12.1 Creating a Thread;
12.2 Making a Resource Thread-Safe;
12.3 Notifying One Thread from Another;
12.4 Initializing Shared Resources Once;
12.5 Passing an Argument to a Thread Function;
Chapter 13: Internationalization;
13.1 Introduction;
13.1 Hardcoding a Unicode String;
13.2 Writing and Reading Numbers;
13.3 Writing and Reading Dates and Times;
13.4 Writing and Reading Currency;
13.5 Sorting Localized Strings;
Chapter 14: XML;
14.1 Introduction;
14.1 Parsing a Simple XML Document;
14.2 Working with Xerces Strings;
14.3 Parsing a Complex XML Document;
14.4 Manipulating an XML Document;
14.5 Validating an XML Document with a DTD;
14.6 Validating an XML Document with a Schema;
14.7 Transforming an XML Document with XSLT;
14.8 Evaluating an XPath Expression;
14.9 Using XML to Save and Restore a Collection of Objects;
Chapter 15: Miscellaneous;
15.1 Introduction;
15.1 Using Function Pointers for Callbacks;
15.2 Using Pointers to Class Members;
15.3 Ensuring That a Function Doesn't Modify an Argument;
15.4 Ensuring That a Member Function Doesn't Modify Its Object;
15.5 Writing an Operator That Isn't a Member Function;
15.6 Initializing a Sequence with Comma-Separated Values;
Colophon;

Read More Show Less

Customer Reviews

Average Rating 5
( 2 )
Rating Distribution

5 Star

(2)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

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 2 Customer Reviews
  • Anonymous

    Posted October 12, 2006

    COOKING WITH C++!!

    Are you a C++ programmer? If you are, then this book is for you. Authors D. Ryan Stephens, Christopher Diggins, Jonathan Turkanis and Jeff Cogswell, have done an outstanding job of writing a book about solving common problems with C++, but not a book about learning C++. Stephens, Diggins, Turkanis and Cogswell, begin by showing you recipes that contain recipes for transforming C++ source code into executable programs and libraries. Then, the authors show you recipes that describe techniques that you apply from within header files. Next, they show you solutions to common problems when working with C++¿s numeric types. The authors also show you recipes for working with strings and text files. They continue with an overview of how to manipulate dates and times. Then, the authors describe the data structures in the standard library that you can use to store data. Next, they describe how to work with the standard algorithms and how to use them on the standard containers. The authors also show you solutions to common problems related to working with C++ classes. They continue by showing you recipes for using C++¿s exception-handling features. Then, the authors present an overview of streams and files. Next, they provide you with solutions to common numerical programming problems and demonstrate how to use generic programming techniques to write numerical code effectively. The authors also describe how to write multithreaded programs in C++ using the Boost Threads library. They continue by describing solutions to some common requirements when internationalizing C++ programs. Then, the authors present an overview of XML. Finally, they describe a few facets of C++ that do not actually fit neatly into any of the other chapters: Function and member pointers, const variables and member functions, and standalone operators and a few other topics. Throughout this most excellent book, the authors give real life solutions that reflect the current best practices in C++ programming. More importantly, they focus on performance and portability, with a strong emphasis on formal and ad hoc standards.

    1 out of 1 people found this review helpful.

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

    Posted April 27, 2008

    C++ Cookbook, the best C++ guide ¿

    When I get a C++ Cookbook to my hand I think what I find in this book? I learn C++ from a much books, and everything it¿s very boring and hardly to learn. My first travel to C++ world with this book is very, very good and I love this book. C++ Cookbook is very friendly and easy to learn, full guide for all people who¿s interesting get a professional information about programming in this language. Four authors in good, practice chapters summary all main and additional programming techniques for C++. All topics illustrated with useful examples from real world. C++ Cookbook have very useful format, all chapters presented problem, detail describe solution and discuss about potential problem and possibilities to quick resolve all hardly point in C++ programming. I think this is the best method to learn for all people, from hobbyst who¿s interesting to discover features in C++ and easy learn to professional who¿s interesting find all required information for realize real-world problem at the C++ solutions. Additional C++ Cookbooks is good pocket reference all features and functions C++ language. You can easily find short information about every features in general C++ language and additional standard libraries. Absolutly great and useful for all people! With this book You can quickly learn C++ and going from novice to professional C++ developer. With this book You can to the TechED events and become a C++ speaker , seriously!

    Was this review helpful? Yes  No   Report this review
Sort by: Showing all of 2 Customer Reviews

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