Defined Terms
begin Member of
stringandvectorthat returns an iterator to the first element. Also, free-standing library function that takes an array and returns a pointer to the first element in the array.buffer overflow Serious programming bug that results when we use an index that is out-of-range for a container, such as a
string,vector, or an array.C-style strings Null-terminated character array. String literals are C-style strings. C-style strings are inherently error-prone.
class template A blueprint from which specific clas types can be created. To use a class template, we must specify additional information. For example, to define a
vector, we specify the element type:vector<int>holdsints.compiler extension Feature that is added to the language by a particular compiler. Programs that rely on compiler extensions cannot be moved easily to other compilers.
container A type whose objects hold a collection of objects of a given type.
vectoris a container type.copy initialization Form of initialization that uses an
=. The newly created object is a copy of the given initializer.difference_type A
signedintegral type defined byvectorandstringthat can hold the distance between any two iterators.direct initialization Form of initialization that does not include an
=.empty Member of
stringandvector. Returnsbool, which istrueifsizeis zero,falseotherwise.end Member of
stringandvectorthat returns an off-the-end iterator. Also, freestanding library function that takes an array and returns a pointer one past the last element in the array.getline Function defined in the
stringheader that takes anistreamand astring. The function reads the stream up to the next newline, storing what it read into thestring, and returns theistream. The newline is read and discarded.index Value used in the subscript operator to denote the element to retrieve from a
string,vector, or array.instantiation Compiler process that generates a specific template class or function.
iterator A type used to access and navigate among the elements of a container.
iterator arithmetic Operations on
vectororstringiterators: Adding or subtracting an integral value and an iterator yields an iterator that many elements ahead of or behind the original iterator. Subtracting one iterator from another yields the distance between them. Iterators must refer to elements in, or off-the-end of the same container.null-terminated string String whose last character is followed by the null character (
'\0').off-the-end iterator The iterator returned by
endthat refers to a nonexistent element one past the end of a container.pointer arithmetic The arithmetic operations that can be applied to pointers. Pointers to arrays support the same operations as iterator arithmetic.
ptrdiff_t Machine-dependent signed integral type defined in the
cstddefheader that is large enough to hold the difference between two pointers into the largest possible array.push_back Member of
vector. Appends elements to the back of avector.range for Control statement that iterates through a specified collection of values.
size Member of
stringandvector. Returns the number of characters or elements, respectively. Returns a value of thesize_typefor the type.size_t Machine-dependent unsigned integral type defined in the
cstddefheader that is large enough to hold the size of the largest possible array.size_type Name of types defined by the
stringandvectorclasses that are capable of containing the size of anystringorvector, respectively. Library classes that definesize_typedefine it as anunsignedtype.string Library type that represents a sequence of characters.
using declarations Make a name from a namespace accessible directly.
makes name accessible without the namespace
::prefix.value initialization Initialization in which built-in types are initialized to zero and class types are initialized by the class’s default constructor. Objects of a class type can be value initialized only if the class has a default constructor. Used to initialize a container’s elements when a size, but not an element initializer, is specified. Elements are initialized as a copy of this compiler-generated value.
vector Library type that holds a collection of elements of a specified type.
++operator The iterator types and pointers define the increment operator to “add one” by moving the iterator to refer to the next element.[ ]operator Subscript operator.obj[i]yields the element at positionifrom the container objectobj. Indices count from zero—the first element is element0and the last is the element indexed byobj.size() - 1. Subscript returns an object. Ifpis a pointer andnan integer,p[n]is a synonym for*(p+n).->operator Arrow operator. Combines the operations of dereference and dot operators:a->bis a synonym for(*a).b.<<operator Thestringlibrary type defines an output operator. Thestringoperator prints the characters in astring.>>operator Thestringlibrary type defines an input operator. Thestringoperator reads whitespace-delimited chunks of characters, storing what is read into the right-hand (string) operand.!operator Logical NOT operator. Returns the inverse of theboolvalue of its operand. Result istrueif operand isfalseand vice versa.&&operator Logical AND operator. Result istrueif both operands aretrue. The right-hand operand is evaluated only if the left-hand operand istrue.||operator Logical OR operator. Yieldstrueif either operand istrue. The right-hand operand is evaluated only if the left-hand operand isfalse.
using namespace::name;