Reading Notes: C ++ cookbook

Source: Internet
Author: User
Tags time zones

This book is not intended for beginners. This book mainly explains how to use some ready-made class libraries, including the C ++ standard library and boost library.

Chapter 4 Create a c ++ Application

1. Compile, Link, static/dynamic library

2. Compiler

3. GNU Compiler set (GCC)

4. Visual C ++

5. Intel Compiler

6. metrowerks Compiler

7. Borland Compiler

8. comeau Compiler

9. Digital Mars Compiler

10. cygwin and mingw

11. Compile the link command

12. Dynamic Link Library

Chapter 4 code structure

2.2 ensure that only one instance exists in a variable that spans multiple source files.

Use extern

2.3 use the forward class Declaration to reduce # Use of include

Using the forward class declaration can reduce compilation dependencies and use the Forward Declaration to create a simple name. Any class in this header file can reference this name. The linker can match the name used in the header file to implement the definition in the file.

2.4 use namespaces to prevent name conflicts

2.5 contains an inline File

Create. the INL file and use # include at the end of your header file to include it. This function is equivalent to placing the function definition at the end of the header file, however, this can separate your declarations and definitions.

Chapter 2 Numerical Calculation

3.1 convert a string to a numeric value

You can use the lexical_cast class of the standard library or boost library.

The strtol function in the standard library can be implemented.

3.2 convert a value to a string

You can use the stringstream class in the standard library to store strings.

The format class in the boost library can also implement this

3.3 test whether the string contains valid values

Use the lexical_cast function template of the boost library to test valid values. This method can contain a minus sign or a plus sign, but cannot contain spaces.

3.5 parse a string containing values expressed in scientific notation

The most direct way to solve this problem is to use the stringstream class in the standard library.

3.6 conversion between different numeric types

Overflow is the most common problem in conversions between different types of values. Use the numeric_cast class template of the boost library for runtime detection. If overflow or underflow occurs, a bad_numeric_cast type exception is thrown.

Chapter 2 string and text

4.1 fill string

The append and insert functions of the string class can be filled with multiple characters.

4.2 crop a string

Erase Functions

4.5 flip string

You can use the reverse function in the standard library.

4.6 split string

Use the find function in the standard library to find the delimiters, and then obtain the corresponding strings.

4.9 search strings

4.10 search for the nth substring

4.11 delete a substring from a string

4.12 convert string to lowercase or uppercase

4.13 case-insensitive string comparison

4.14 case-insensitive string SEARCH

4.15 convert tabs and spaces in text files

4.16 line feed in text files

4.17 calculate the number of characters, number of words, and number of lines in a text file

4.18 calculate the number of occurrences of each word in a text file

4.19 add blank content to text files

4.20 adjust text files

4.21 compress multiple spaces in a text file into one

4.22 automatically correct text

4.23 read text files separated by commas

4.24 use regular expressions to separate strings

You need to use the RegEx library in boost. Note that you need to specify the library to be loaded during compilation.

G ++-lboost_regex-O helloworld. CC

 

Chapter 2 Date and Time

5.0 Overview

5.1 obtain the current date and time

5.2 format the date/time as a string

5.3 Date and Time operations

5.4 convert between time zones

5.5 determine the day of the year

5.6 define Restricted Data Types

Chapter 4 Data Management

6.0 Overview

6.1 use vector instead of Array

6.2 use vector efficiently

6.3 vector replication

6.4 store pointers in Vectors

6.5 store objects in the linked list

6.6 map strings to other things

6.7 use a hash function

6.8 storage objects in sequence

6.9 container storage

Chapter 1 Algorithms

7.0 Overview

7.1 traverse containers

7.2 delete an object

7.3 random data disruption

7.4 comparison Element

7.5 Merge data

7.6 arrange Elements

7.7 split Element

7.8 perform set operations on Sequences

7.9 sequence element Conversion

7.10 compile your own algorithms

7.11 output elements to the data stream

Chapter 1 category

8.0 Overview

8.1 initialize class member variables

8.2 use functions to create objects

8.3 Use constructors and destructor to manage resources

8.4 automatically add a new class instance

8.5 make sure that one member variable has only one copy

8.6 determine the object type at runtime

8.7 determine whether the class of an object is a subclass of another class

8.8 specify a unique identifier for each instance of the class.

8.9 create a single class

8.10 create an interface with abstract base classes

8.11 compile a class template

8.12 compile a member function template.

8.13 overload auto-increment and auto-subtraction Operators

8.14 overload arithmetic and value assignment operators for intuitive Behaviors

8.15 call a super-class virtual function

Chapter 2 exceptions and security

9.0 Overview

9.1 create an exception class

9.2 create an exception-safe Constructor

9.3 create an exception-safe initialization list

9.4 create a member function with exceptional security

9.5 securely copy an object

Chapter 4 data streams and files

10.0 Overview

10.1 text output alignment

10.2 format floating point output

10.3 compile your own stream operation program

10.4 make the class writable into the stream

10.5 make the stream readable class

10.6 obtain file information

10.7 copy a file

10.8 delete or rename an object

10.9 create a temporary file name and file

10.10 create a directory

10.11 delete a directory

10.12 read contents of the Directory

10.13 extract file extensions from strings

10.14 extract the file name from the complete path

10.15 extract the path from the complete path and file name

10.16 Replace the file extension

10.17 combine two paths into one path

Chapter 2 scientific and mathematical computing

11.0 Overview

11.1 calculate the number of elements in a container

11.2 find the maximum or minimum value

11.3 calculate sum and average value

11.4 filter out values beyond the specified range

11.5 variance, standard deviation, and other statistical function calculations

11.6 generate random number

11.7 use a random number to initialize the container

11.8 represents a variable number of numeric Vectors

11.9 indicates a fixed number of numeric Vectors

11.10 dot product computing

11.11 calculate the Vector norm

11.12 calculate the distance between two vectors

11.13 implement a cross-step iterator

11.14 implement a variable-size Matrix

11.15 implement a fixed-size Matrix

11.16 Matrix Multiplication

11.17 computation Fast Fourier Transformation

11.18 use Polar Coordinates

11.19 perform arithmetic operations on the in-place set

11.20 represents a large integer with a fixed width

11.21 implement fixed decimal point values

Chapter 2 Multithreading

12.0 Overview

12.1 create a thread

12.2 make resources thread-safe

12.3 send notifications from one thread to another

12.4 initialize shared resources only once

12.5 pass a parameter to the thread function

Chapter 1 Globalization

13.0 Overview

13.1 hard-coded Unicode string

13.2 read numbers

13.3 read Date and Time

13.4 read currency value

13.5 sort local strings

Chapter 2 XML

14.0 Overview

14.1 parse a simple XML document

14.2 use the xerces string

14.3 parse a complex XML document

14.4 XML document operations

14.5 use DTD to verify an XML document

14.6 use schema to verify an XML document

14.7 use XSLT to convert an XML document

14.8 evaluate an XPATH expression

14.9 use XML to save and restore an object set

Chapter 4 Miscellaneous

15.0 Overview

15.1 use function pointer for callback

15.2 use a pointer to a class member

15.3 ensure that the function does not modify parameters

15.4 ensure that the member function does not modify its object

15.5 compile an operator that is not a member function

15.6 initialize a comma-separated Series

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.