"C + + primer daily Brush Five" standard library type Summary

Source: Internet
Author: User
Tags bitset


Summary of standard library types

The C + + standard library defines several more advanced types of abstract data, including string and vector classes type. String types provide variable-length strings, while vector types can be used to manage the same type

collection of objects. iterators Implement indirect access to objects stored in containers. Iterators can be used to access and iterate over elements of type string and vectors types. The following section describes the built-in data types for C + +: arrays and pointers. Both types provide a low-level abstraction type similar to the vector and string standard library types. In general, programmers should take precedence over the standard library class types relative to the C + + inline data type arrays and pointers.

standard library Terminology Section Abstract Data Type

hides the data type that it implements. When you use an abstract data type, you only need to understand the operations supported by that type .

Bitset

A standard library type that is used to save locations and provide testing and placement operations for each bit of the site.

Cctype Header (cctype header file)

A header file inherited from the C standard library that contains a set of routines that test character values.


class Template


a blueprint that can create many potential class types. When you use a class template, you must give the actual type and value. For example, a vector type is a template that holds objects of a given type. To create a vector object, you must indicate the type of element that this vector object holds. Vector<int> holds an int object, while vector<string> saves the string object, and so on. container (container) a type whose object holds a collection of objects of a given type.

Difference_type

A signed integral type defined by the vector type for storing any two iterators between

Distance.

Empty

member functions defined by the string type and the vector type. Empty returns a Boolean value that detects whether a string has characters or whether the vector has elements. returns True if the size of string or vector is 0, otherwise false.

Getline

A function defined in the string header file that accepts a IStream object and a string object that reads the input stream until the next newline character, storing the input stream read into the string object and returns the IStream object. NewLine characters are read in and discarded.

High-order (Advanced)

The largest bit of the index value in the Bitset object.

Index (indexed)

The value used by the subscript operator to represent the object obtained from a string object or vector element. Also called "Subscript".

iterator (iterator)

The type of data used to inspect and traverse the elements of the container type.

iterator arithmetic (arithmetic operation of the iterator)

arithmetic operations applied to some (not all) iterator types. An iterator object can add or subtract an integer value, and the result iterator points to the position of several elements before or after the original iterator . Two iterator objects can be subtracted, resulting in the distance between them. An iterator arithmetic operation applies only to elements that point to the same container or to the next element iterator that points to the end of the container .


Low-order (Low order)

The bit with the smallest index value in the Bitset object.

Off-the-end iterator (iterator beyond the end)

An iterator returned by the end operation, which is an iteration that points to a nonexistent element after the end of the container

Manager

push_back

a member function defined by a vector type that appends an element to the tail of a vector object. Sentinel (Sentinel) A programming technique that uses a value to control the processing process. Use the iterator returned by the end operation as the protector in this chapter, and use it to stop processing the elements in the vector when all the elements in the vector object have been processed .

size

functions defined by the library type string, vector, and bitset, respectively, to return the three classes the number of characters, elements, and bits of a type. The size member function of the string and vector classes Returns a value of type size_type (for example, the size operation of a String object returns the string::size_type type value). The size operation of the Bitset object returns the size_t type value.

size_t

The machine-related unsigned integer defined in the Cstddef header file, which is sufficient to hold the maximum the length of the array. the machine-related unsigned integer defined in the Cstddef header file, which is sufficient to hold the largest array of

Length.

Size_type

a type defined by the string class type and the vector class type to hold any string pair the length of the image or Vecotr object. The standard library type defines size_type as the unsigned type.

using declarations (using declaration)

The name of the namespace can be referenced directly. Like what:

Using Namespace::name;

The name can be accessed directly without the prefix namespace::.

Value initialization (initialization of values)

when the length of a given container, but does not explicitly provide an initial type of element, the container element is initialized. The element is initialized to a copy of the value produced by the compiler. If the container holds a built-in type variable, the initial value of the element is set to 0. If the container is used to hold the class object, the initial value of the element is generated by the class's default constructor. Container elements of class class type can be initialized only when the class provides a default constructor .


+ + operator (+ + operator)

An increment operator for an iterator type definition that points to the next element through the "plus 1" move iterator The .


:: operator (:: operator)

The scope operator. :: The operator finds the name of its right operand within the scope of its left operand . Used to access names in a namespace, such as std::cout, to indicate that the name cout comes from the namespace Std. Similarly, you can use a name from a class, such as String::size_type, to indicate that size_type is defined by the string class.

[] Operator ([] operator)

the overloaded operator defined by the string, vector, and bitset types. It accepts two operands: the left operand is the object name, and the right operand is an index. This operator is used to remove the element that corresponds to the anchor, the index count starts at 0, that is, the first element is indexed to 0, and the last element is indexed as obj.size ()-1. The subscript operation returns an lvalue, so the subscript operation can be used as the left operand of an assignment operation. Assigning a value to the result of the subscript operation is to assign a new value to the corresponding element .

* operator (* operator)

The iterator type definition understands the reference operator to return the object that the iterator points to. Dereference returns an lvalue, so the dereference operator can be used as the left operand of an assignment operation. Assigning a value to the result of a dereference operation is to assign a new value to the corresponding element.

<< operator (<< operator)

the standard library type string and Bitset define the output operator. The output operator of type string outputs the characters in the string object. The output operator of the Bitset type outputs the bit pattern of the Bitset object.

>> operator (>> operator)

the standard library type string and Bitset define the input operators. The input operator of the string type reads a string that is delimited by a white-space character and stores the read-in content in the right-hand operand (String object). The input operator of the Bitset type reads into a bit sequence into its bitset operand.

"C + + primer daily Brush Five" standard library type Summary

Related Article

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.