C++ Cookbook
Home > Computing and Information Technology > Computer programming / software engineering > Programming and scripting languages: general > C++ Cookbook
C++ Cookbook

C++ Cookbook

|
     0     
5
4
3
2
1




International Edition


About the Book

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.

Table of Contents:
Preface 1. Building C++ Applications 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 2. Code Organization 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 3. Numbers 3.1 Converting a String to a Numeric Type 3.2 Converting Numbers to Strings 3.3 Testing Whether a String ontains 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 4. Strings and Text 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 5. Dates and Times 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 6. Managing Data with Containers 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 7. Algorithms 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 8. Classes 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 9. Exceptions and Safety 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 Object10. Streams and Files 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 Path11. Science and Mathematics 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 12. Multithreading 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 13. Internationalization 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 14. XML 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 Objects15. Miscellaneous 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 Index


Best Sellers


Product Details
  • ISBN-13: 9780596007614
  • Publisher: O'Reilly Media
  • Publisher Imprint: O'Reilly Media
  • Height: 225 mm
  • No of Pages: 594
  • Returnable: Y
  • Width: 175 mm
  • ISBN-10: 0596007612
  • Publisher Date: 13 Dec 2005
  • Binding: Paperback
  • Language: English
  • Returnable: Y
  • Spine Width: 35 mm


Similar Products

Add Photo
Add Photo

Customer Reviews

REVIEWS      0     
Click Here To Be The First to Review this Product
C++ Cookbook
O'Reilly Media -
C++ Cookbook
Writing guidlines
We want to publish your review, so please:
  • keep your review on the product. Review's that defame author's character will be rejected.
  • Keep your review focused on the product.
  • Avoid writing about customer service. contact us instead if you have issue requiring immediate attention.
  • Refrain from mentioning competitors or the specific price you paid for the product.
  • Do not include any personally identifiable information, such as full names.

C++ Cookbook

Required fields are marked with *

Review Title*
Review
    Add Photo Add up to 6 photos
    Would you recommend this product to a friend?
    Tag this Book Read more
    Does your review contain spoilers?
    What type of reader best describes you?
    I agree to the terms & conditions
    You may receive emails regarding this submission. Any emails will include the ability to opt-out of future communications.

    CUSTOMER RATINGS AND REVIEWS AND QUESTIONS AND ANSWERS TERMS OF USE

    These Terms of Use govern your conduct associated with the Customer Ratings and Reviews and/or Questions and Answers service offered by Bookswagon (the "CRR Service").


    By submitting any content to Bookswagon, you guarantee that:
    • You are the sole author and owner of the intellectual property rights in the content;
    • All "moral rights" that you may have in such content have been voluntarily waived by you;
    • All content that you post is accurate;
    • You are at least 13 years old;
    • Use of the content you supply does not violate these Terms of Use and will not cause injury to any person or entity.
    You further agree that you may not submit any content:
    • That is known by you to be false, inaccurate or misleading;
    • That infringes any third party's copyright, patent, trademark, trade secret or other proprietary rights or rights of publicity or privacy;
    • That violates any law, statute, ordinance or regulation (including, but not limited to, those governing, consumer protection, unfair competition, anti-discrimination or false advertising);
    • That is, or may reasonably be considered to be, defamatory, libelous, hateful, racially or religiously biased or offensive, unlawfully threatening or unlawfully harassing to any individual, partnership or corporation;
    • For which you were compensated or granted any consideration by any unapproved third party;
    • That includes any information that references other websites, addresses, email addresses, contact information or phone numbers;
    • That contains any computer viruses, worms or other potentially damaging computer programs or files.
    You agree to indemnify and hold Bookswagon (and its officers, directors, agents, subsidiaries, joint ventures, employees and third-party service providers, including but not limited to Bazaarvoice, Inc.), harmless from all claims, demands, and damages (actual and consequential) of every kind and nature, known and unknown including reasonable attorneys' fees, arising out of a breach of your representations and warranties set forth above, or your violation of any law or the rights of a third party.


    For any content that you submit, you grant Bookswagon a perpetual, irrevocable, royalty-free, transferable right and license to use, copy, modify, delete in its entirety, adapt, publish, translate, create derivative works from and/or sell, transfer, and/or distribute such content and/or incorporate such content into any form, medium or technology throughout the world without compensation to you. Additionally,  Bookswagon may transfer or share any personal information that you submit with its third-party service providers, including but not limited to Bazaarvoice, Inc. in accordance with  Privacy Policy


    All content that you submit may be used at Bookswagon's sole discretion. Bookswagon reserves the right to change, condense, withhold publication, remove or delete any content on Bookswagon's website that Bookswagon deems, in its sole discretion, to violate the content guidelines or any other provision of these Terms of Use.  Bookswagon does not guarantee that you will have any recourse through Bookswagon to edit or delete any content you have submitted. Ratings and written comments are generally posted within two to four business days. However, Bookswagon reserves the right to remove or to refuse to post any submission to the extent authorized by law. You acknowledge that you, not Bookswagon, are responsible for the contents of your submission. None of the content that you submit shall be subject to any obligation of confidence on the part of Bookswagon, its agents, subsidiaries, affiliates, partners or third party service providers (including but not limited to Bazaarvoice, Inc.)and their respective directors, officers and employees.

    Accept

    New Arrivals

    Inspired by your browsing history


    Your review has been submitted!

    You've already reviewed this product!