TOC PREV NEXT INDEX

C++: A Dialog


APPENDIX B Glossary


Special Characters

& has a number of distinct meanings. When it precedes the name of a variable without following the name of a type, it means "the address of the following variable". For example, &Str means "the address of the variable Str". When & follows a type name and precedes a variable name, it means that the variable being declared is a reference - that is, another name for a preexisting variable. In this book, references are used only in argument lists, where they indicate that the variable being defined is a new name for the caller's variable rather than a new local variable.
% is the "modulus" operator, which returns the remainder after dividing its left-hand argument by its right-hand argument.
:: is the scope resolution operator, which is used to tell the compiler the scope of a variable. We can prefix it to the name of a global variable to prevent the compiler from confusing it with a variable of the same name from the standard library. It is also used to specify the namespace or class of a variable or function, when placed between the namespace or class name and the variable or function name.
< is the "less than" operator, which returns the value true if the expression on its left has a lower value than the expression on its right; otherwise, it returns the value false. Also see operator < in the index.
<< is the "stream output" operator, used to write data to an ostream. Also see operator << in the index.1
<= is the "less than or equal to" operator, which returns the value true if the expression on its left has the same or a lower value than the expression on its right; otherwise, it returns the value false. Also see operator <= in the index.
= is the assignment operator, which assigns the value on its right to the variable on its left. Also see operator = in the index.
== is the "equals" operator, which returns the value true if the expression on its left has the same value as the expression on its right; otherwise, it returns the value false. Also see operator == in the index.
> is the "greater than" operator, which returns the value true if the expression on its left has a greater value than the expression on its right; otherwise, it returns the value false. Also see operator > in the index.
>= is the "greater than or equal to" operator, which returns the value true if the expression on its left has the same or a greater value than the expression on its right; otherwise, it returns the value false. Also see operator >= in the index.
>> is the "stream input" operator, used to read data from an istream. Also see operator >> in the index.
[ is the left square bracket; see square brackets for usage.
] is the right square bracket; see square brackets for usage.
[ ] is used after the delete operator to tell the compiler that the pointer for which delete was called refers to a group of elements rather than just one data item, e.g., when deleting an array of chars. This is one of the few times when we have to make that distinction explicitly rather than leaving it to context.
{ is the left curly brace; see curly braces for usage.
} is the right curly brace; see curly braces for usage.
!= is the "not equals" operator, which returns the value true if the expression on its left has a value different from the expression on its right; otherwise, it returns the value false. Also see operator != in the index.
&& is the "logical AND" operator. It produces the result true if the expressions on both its right and left are true; if either of those expressions is false, it produces the result false. However, this isn't the whole story. There is a special rule in C++ governing the execution of the && operator: If the expression on the left is false, then the answer must be false and the expression on the right is not executed at all. The reason for this short-circuit evaluation rule is that in some cases you may want to write a right-hand expression that will only be valid if the left-hand expression is true.
++ is the increment operator, which adds 1 to the variable to which it is affixed.
+= is the "add to variable" operator, which adds the value on its right to the variable on its left.
-= is the "subtract from variable" operator, which subtracts the value on its right from the variable on its left.
// is the comment operator; see comment for usage.
|| is the "logical OR" operator. It produces the result true if at least one of the two expressions on its right and left is true; if both expressions are false, it produces the result false. However, there is a special rule in C++ governing the execution of the || operator: if the expression on the left is true, then the answer must be true and the expression on the right is not executed at all. The reason for this short-circuit evaluation rule is that in some cases you may want to write a right-hand expression that will only be valid if the left-hand expression is false.
A #define statement is a preprocessor directive that defines a preprocessor symbol. While this statement can be used to define constant values for general use, it has been mostly superseded except as part of the include guard mechanism.
An #endif statement is a preprocessor directive that terminates a section of conditional code. It is used in this book as part of the include guard mechanism.
An #ifdef statement is a preprocessor directive that begins a section of conditional code. It has the opposite effect from the #ifndef directive.
An #ifndef statement is a preprocessor directive that tells the preprocessor to check whether a particular preprocessor symbol has been defined. If not, the following source code is treated normally. However, if the specified preprocessor symbol has been defined, the following source code is skipped by the rest of the compiler as though it were not present in the source file. The #ifndef statement is used in this book as part of the include guard mechanism.
An #include statement is a preprocessor directive that has the same effect as that of copying all of the code from a specified file into another file at the point where the #include statement is written. For example, if we wanted to use definitions contained in a file called xstream.h in the implementation file test.cpp, we could insert the include statement #include "xstream.h" in test.cpp rather than physically copying the lines from the file xstream.h into test.cpp.

A

An access specifier controls the access of nonmember functions to the member functions and variables of a class. The C++ access specifiers are public, private, and protected. See public, private, and protected for details. Also see friend.
Access time is a measure of how long it takes to retrieve data from a storage device, such as a hard disk or RAM.
Address; see memory address.
An algorithm is a set of precisely defined steps guaranteed to arrive at an answer to a problem or set of problems. As this implies, a set of steps that might never end is not an algorithm in the strictest sense.
Aliasing is the practice of referring to one object by more than one "name"; in C++, these names are actually pointers or references.
The aliasing problem is a name for the difficulties that are caused by altering a shared object.
An application program is a program that actually accomplishes some useful or interesting task. Examples include inventory control, payroll, and games.
An application programmer (or class user) is a programmer who uses native and class variables to write an application program. Also see library designer.
An argument is a value supplied by one function (the calling function) that wishes to make use of the services of another function (the called function). There are two main types of arguments: value arguments, which are copies of the values from the calling function, and reference arguments, which are not copies but actually refer to variables in the calling function.
An argument list is a set of argument definitions specified in a function declaration. The argument list describes the types and names of all the variables the function receives when it is called by a calling function.
An array is a group of elements of the same type - for example, an array of chars. The array name corresponds to the address of the first of these elements; the other elements follow the first one immediately in memory. As with a vector, we can refer to the individual elements by their indexes. Thus, if we have an array of chars called m_Data, m_Data[i] refers to the ith char in the array. Also see pointer, vector.
An array initialization list is a list of values used to initialize the elements of an array. The ability to specify a list of values for an array is built into the C++ language and is not available for user-defined data types such as the vector.
The ASCII code is a standardized representation of characters by binary or hexadecimal values. For example, the letter "A" is represented as a char with the hexadecimal value 41, and the digit 0 is represented as a char with the hexadecimal value 30. All other printable characters also have representations in the ASCII code.
An assembler is a program that translates assembly language instructions into machine instructions.
An assembly language instruction is the human-readable representation of a machine instruction.
Assignment is the operation of setting a variable to a value. The operator that indicates assignment is the equal sign, =. Also see operator = in the index.
An assignment operator is a function that sets a preexisting variable to a value of the same type. There are three varieties of assignment operators:
1. For a variable of a native type, the compiler supplies a native assignment operator.
2. For a variable of a class type, the compiler generates its own version of an assignment operator (a compiler-generated assignment operator) if the class writer does not write one.
3. The class writer can write a member function (a user-defined assignment operator) to do the assignment; see operator = in the index.
An assignment statement such as x = 5; is not an algebraic equality, no matter how much it may resemble one. It is a command telling the compiler to assign a value to a variable. In the example, the variable is x and the value is 5.
The auto storage class is the default storage class for variables declared within C++ functions. When we define a variable of the auto storage class, its memory address is assigned automatically upon entry to the function where it is defined; the memory address is valid for the duration of that function.
Automatic conversion is a feature of C++ that allows an expression of one type to be used where another type is expected. For example, a short variable or expression can be provided when an int expression is expected, and the compiler will convert the type of the expression automatically.

B

Base class: see inheritance.
A base class initializer specifies which base class constructor we want to use to initialize the base class part of a derived class object. It is one of the two types of expressions allowed in a member initialization list. Also see inheritance, constructor.
The base class part of a derived class object is an unnamed component of the derived class object whose member variables and functions are accessible as though they were defined in the derived class, so long as they are either public or protected.
A batch file is a text file that directs the execution of a number of programs, one after the other, without manual intervention. A similar facility is available in most operating systems.
A binary number system uses only two digits, 0 and 1.
A bit is the fundamental unit of storage in a modern computer; the word bit is derived from the phrase binary digit. Each bit, as this suggests, can have one of two states: 0 and 1.
A block is a group of statements considered as one logical statement. It is delimited by the curly braces, { and }. The first of these symbols starts a block, and the second one ends it. A block can be used anywhere that a statement can be used and is treated exactly as if it were one statement. For example, if a block is the controlled block of an if statement, all of the statements in the block are executed if the condition in the if is true, and none is executed if the condition in the if is false.
A bool (short for Boolean) is a type of variable whose range of values is limited to true or false. This is the most appropriate return type for a function that uses its return value to report whether some condition exists, such as operator <. In that particular case, the return value true indicates that the first argument is less than the second, while false indicates that the first argument is not less than the second.
Brace; see curly braces.
A break statement is a loop control device that interrupts the processing of a loop whenever it is executed within the controlled block of a loop control statement. When a break statement is executed, the flow of control passes to the next statement after the end of the controlled block.
A buffer is a temporary holding place where information is stored while it is being manipulated.
Buffering is the process of using a buffer to store or retrieve information.
A byte is the unit in which data capacities are stated, whether in RAM or on a disk. In most modern computers, a byte consists of eight bits.

C

A C function is one that is inherited from the C library. Because C does not have a number of features that have been added in C++, such as function overloading and reference arguments, C functions must often be called in different ways from those we use when calling a C++ function.
The C standard library is a part of the C++ standard library. It consists of a collection of functions that were originally written for users of the C programming language. Because C++ is a descendant of C, these functions are often still useful in C++ programs.
The C++ standard library is a collection of code defined by the ISO (International Standards Organization), that must be included with every standards-compliant compiler. Unfortunately, as of this writing, there are no completely standards-compliant compilers, but the one on the CD in the back of the book should be close enough for programs you will be writing. The types defined in the standard library include the vector and string classes that we have used either directly or indirectly throughout this book, as well as hundreds of other very useful types and functions.
A C string is a sequence of characters referred to by a char* pointer. Do not confuse this with the C++ string class.
A C string literal is a literal value representing a variable number of characters. An example is "This is a test.". C string literals are surrounded by double quotes ("). The name of this data type indicates its origin in C, which did not have a real string type such as the C++ string. While these two types have some similarities, they behave quite differently and should not be confused with one another.
A cache is a small amount of fast memory where frequently used data is stored temporarily.
Call; see function call or call instruction.
A call instruction is an assembly language instruction used to implement a function call. It saves the program counter on the stack and then transfers execution from the calling function to the called function.
A called function is a function that starts execution as the result of a function call. Normally, it returns to the calling function via a return statement when finished.
A calling function is a function that suspends execution as a result of a function call; the called function begins execution at the point of the function call.
The carriage return character is used to signal the end of a line of text. Also see newline in the index.
A function is said to be case-sensitive if upper- and lower-case letters are considered to be distinct.
A function is said to be case-insensitive if upper- and lower-case letters are considered equivalent. See less_nocase in the index.
To catch an exception means to handle an interruption in the normal flow control of a program, usually due to an error condition. An exception is generated via a throw statement, and can be caught in a function that has directly or indirectly called the function that threw the exception. The catch keyword is used in conjunction with try, which specifies a block of code to which a specific catch statement or statements may be applicable. A catch can specify the type of exceptions that it will handle, or can use "..." to specify that it will handle any and all exceptions.
A char is an integer variable type that can represent either one character of text or a small whole number. Both signed and unsigned chars are available for use as "really short" integer variables; a signed char can represent a number from -128 to +127, whereas an unsigned char can represent a number from 0 to 255. (In case you were wondering, the most common pronunciation of char has an "a" as in "married", while the "ch" sounds like "k". Other pronunciations include the standard English pronunciation of "char" as in overcooking meat, and even "car" as in "automobile".)2
A char* (pronounced "char star") is a pointer to (i.e., the memory address of) a char or the first of a group of chars.
Child class: see inheritance.
cin (pronounced "see in") is a predefined istream; it gets its characters from the keyboard.
A class is a user-defined type; for example, std::string is a class.
A class designer is a programmer who designs classes. Also see application programmer.
A class implementation tells the compiler how to implement the facilities defined in the class interface. It is usually found in an implementation file, which the compiler on the CD in the back of this book assumes has the extension .cpp.
A class interface tells the user of the class what facilities the class provides by specifying the class's public member functions. The class interface also tells the compiler what data elements are included in objects of the class, but this is not logically part of the interface. A class interface is usually found in a header file - that is, one with the extension .h.
The class membership operator, ::, indicates which class a function belongs to. For example, the full name of the default constructor for the string class is string::string().
class scope describes the visibility of member variables - that is, those defined within a class. A variable with this scope can be accessed by any member function of its class; its accessibility to other functions is controlled by the access specifier in effect when it was defined in the class interface.
A comment is a note to yourself or another programmer; it is ignored by the compiler. The symbol // marks the beginning of a comment; the comment continues until the end of the line containing the //. For those of you with BASIC experience, this is just like REM (the "remark" keyword) - anything after it on a line is ignored by the compiler.
Compilation is the process of translating source code into an object program, which is composed of machine instructions along with the data needed by those instructions. Virtually all software is created by this process.
A compiler is a program that performs compilation.
A compiler-generated function is supplied by the compiler because the existence of that function is fundamental to the notion of a concrete data type. The compiler will automatically generate its own version of any of the following functions if they are not provided by the creator of the class: the assignment operator, the copy constructor, the default constructor, and the destructor.
A compiler warning is a message from the compiler informing the programmer of a potentially erroneous construct. While a warning does not prevent the compiler from generating an executable program, a wise programmer will heed such warnings, as they often reveal hazardous coding practices.
Compile time means "while the compiler is compiling the source code of a program".
Concatenation is the operation of appending a string to the end of another string. Also see operator + in the index.
A concrete data type is a class whose objects behave like variables of native data types. That is, the class gives the compiler enough information that objects of that class can be created, copied, assigned, and automatically destroyed at the end of their useful lifetimes, just as native variables are.
A console mode program is a program that looks like a DOS program rather than a Windows program.
The keyword const has two distinct meanings as employed in this book. The first is as a modifier to an argument of a function. In this context, it means that we are promising not to modify the value of that argument in the function. An example of this use might be the function declaration string& operator = (const string& Str);. The second use of const in this book is to define a data item similar to a variable, except that its value cannot be changed once it has been initialized. For this reason, it is mandatory to supply an initial value when creating a const. An example of this use is const short x = 5;.
A constructor is a member function that creates new objects of a (particular) class type. All constructors have the same name as that of the class for which they are constructors; for example, the constructors for the string class have the name string. A constructor that takes only one required argument is also a conversion function.
A continuation expression is the part of a for statement computed before every execution of the controlled block. The block controlled by the for will be executed if the result of the computation is true but not if it is false. See for statement for an example.
The continue keyword causes execution of a for loop to continue to the next iteration without executing any further statements in the current iteration.
A controlled block is a block under the control of a loop control statement or an if or else statement. The controlled block of a loop control statement can be executed a variable number of times, whereas the controlled block of an if or else statement is executed either once or not at all.
Controlled statement; see controlled block.
A conversion function is a member function that converts an object of its class to some other type, or vice versa. Also see implicit conversion.
A copy constructor makes a new object with the same contents as an existing object of the same type.
cout (pronounced "see out") is a predefined ostream; characters sent to it are displayed on the screen.
CPU is an abbreviation for Central Processing Unit. This is the "active" part of your computer, which executes all the machine instructions that make the computer do useful work.
The curly braces { and } are used to surround a block. The compiler treats the statements in the block as one statement.
A cursor is an abstract object that represents the position on the screen where input or output will occur next.

D

Data refers to the pieces of information that are operated on by programs. Originally, "data" was the plural of "datum"; however, the form "data" is now commonly used as both singular and plural.
A day number is an integer value representing the number of days between two dates.
A debugger is a program that controls the execution of another program so that you can see what the latter program is doing. You can download a debugger from the WWW that is compatible with the development environment on the CD in the back of this book.
Debugging is the art of finding and eradicating errors (bugs) from your program. One of the best ways of debugging a program is to try to explain it to someone else in great detail. If you don't see your error, the other person almost certainly will!
A dedicated register is a register such as the stack pointer whose usage is predefined rather than determined by the programmer, as in the case of general registers such as eax.
A default argument is a method of specifying a value for an argument to a function when the user of the function doesn't supply a value for that argument. The value of the default argument is specified in the declaration of the function.
A default constructor is a member function that is used to create an object when no initial value is specified for that object. For example, string::string() is the default constructor for the string class.
The default keyword is used with the