KeytermDefined Terms


Defined Terms

C-style strings

C programs treat pointers to null-terminated character arrays as strings. In C++, string literals are C-style strings. The C library defines a set of functions that operate on such strings, which C++ makes available in the cstring header. C++ programs should use C++ library strings in preference to C-style strings, which are inherently error-prone. A sizeable majority of security holes in networked programs are due to bugs related to using C-style strings and arrays.



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.



compound type

Type that is defined in terms of another type. Arrays, pointers, and references are compound types.



const void*

A pointer type that can point to any const type. See void*.



delete expression

A delete expression frees memory that was allocated by new:

      delete [] p; 

where p must be a pointer to the first element in a dynamically allocated array. The bracket pair is essential: It indicates to the compiler that the pointer points at an array, not at a single object. In C++ programs, delete replaces the use of the C library free function.



dimension

The size of an array.



dynamically allocated

An object that is allocated on the program's free store. Objects allocated on the free store exist until they are explicitly deleted.



free store

Memory pool available to a program to hold dynamically allocated objects.



heap

Synonym for free store.



new expression

Allocates dynamic memory. We allocate an array of n elements as follows:

      new type[n]; 

The array holds elements of the indicated type. new returns a pointer to the first element in the array. C++ programs use new in place of the C library malloc function.



pointer

An object that holds the address of an object.



pointer arithmetic

The arithmetic operations that can be applied to pointers. An integral type can be added to or subtracted from a pointer, resulting in a pointer positioned that many elements ahead or behind the original pointer. Two pointers can be subtracted, yielding the difference between the pointers. Pointer arithmetic is valid only on pointers that denote elements in the same array or an element one past the end of that array.



precedence

Defines the order in which operands are grouped with operators in a compound expression.



ptrdiff_t

Machine-dependent signed integral type defined in cstddef header that is large enough to hold the difference between two pointers into the largest possible array.



size_t

Machine-dependent unsigned integral type defined in cstddef header that is large enough to hold the size of the largest possible array.



* operator

Dereferencing a pointer yields the object to which the pointer points. The dereference operator returns an lvalue; we may assign to the value returned from the dereference operator, which has the effect of assigning a new value to the underlying element.



++ operator

When used with a pointer, the increment operator "adds one" by moving the pointer to refer to the next element in an array.



[] operator

The subscript operator takes two operands: a pointer to an element of an array and an index. Its result is the element that is offset from the pointer by the index. Indices count from zerothe first element in an array is element 0, and the last is element size of the array minus 1. The subscript operator returns an lvalue; we may use a subscript as the left-hand operand of an assignment, which has the effect of assigning a new value to the indexed element.



& operator

The address-of operator. Takes a single argument that must be an lvalue. Yields the address in memory of that object.



void*

A pointer type that can point to any nonconst type. Only limited operations are permitted on void* pointers. They can be passed or returned from functions and they can be compared with other pointers. They may not be dereferenced.





C++ Primer
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2006
Pages: 223
Authors: Stephen Prata

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net