AD408 Advanced

Advanced Section

TERMS

abstract data type

A data type with an associated set of operations that can be performed on an instance of that data type. Abstract data types give no indication of the actual data type used to implement their operations. Thus, the actual implementation of an abstract data type can change without disruption to the user of that data type. Common examples are lists, datababases and any C++ class.

accessor function

Name given to a class member fuction that returns a variable maintained by the class. The variable maintained by the class may or may not be an actual member variable. Accessor functions are used to implement data encapsulation and maintain abstract data typing.

arguments

Values passed to a function. These may include regular data types such as floats and integers, abstract data types such as classes and lists, or pointers to objects such as dynamically allocated memory or instances of regular data types and classes.

argument signature

The number and data type of arguments given to a function along with the type of the return argument. The argument signature of a function allows the C++ compiler to recognize the actual function to call when functions are overloaded.

base-class

Any class from which a class is derived; also called the parent class. Often the highest class in a class hierarchy is refered to as the base-class.

block

A section of code that defines a separate scope. A block is usually encompasses by a set of curly brackets or found within a function, if-then-else or while statement.

class

The basic C++ construct for abstract data types. The class construct provides facilities for handling member variable access and associated class functions called member variables. The class construct is similiar to the C style struct construct in syntax.

compilation

The interpretation and conversion of a programming language into machine language. Compilled pieces of code can only be executed on the machine for which they were created but are otherwise the basis for portable code libraries. Compilation is the first step in the two step process of compilation and linking that is required to produce executable code.

constructor

A class function that is called when the an istance of the class is created. The constructor is used to initialize the state of the class and may be repeated with different argument signatures. The class constructor is given the same name as the class and has no return argument. A default constructor is created if one is not declared.

data encapsulation

The philosophy of hiding all data behind an interface to the abstract data type. Data encapsulation aids in making the data type resilient to implementation change, preventing unexpected error conditions, and providing data security. Data encapsulation is a necessary feature of object oriented programming.

declaration

Variables and functions must be declared to the C or C++ comiller before they can be refered to in another declaration of a class or function. Function declarations are required for code compilation, but function definitions are not required. Compiled function definitions must be availlable for linking.

destructor

A class function that is called when an istance of a class is destroyed. The destructor is used to take care of any necessary cleanup before the class is deleted. Destructors are often used to delete dynamically memory allocated by the class. The class destructor is given the same name as the class preceded by a tilda(~) and has not return argument. A default destructor is created if one is not declared.

dynamic memory

Memory allocated dynamically by the executing program. Dynamic memory is usually taken from a reserved area called the heap. Dynamic memory is not automatically recollected in C++ and must be returned to the system with the delete statement. Because dynamic memory is not subject to scoping rules it can be used by in any place within the program, provided a pointer to the address of the memory is maintained.

function definition

The actual implementation of a declared function. The definition of a function need not be included in the declaration of a function but must follow it.

function overriding

The overriding of a function by a sub-class. A sub-class may override a member function that has been declared as a virtual function. When an instance of the sub-class is called, the overriden function will be called. The overriden function must have the same argument signature and name as the function from the parent class.

function overloading

The creation of multiple functions having the same name but multiple argument signatures. Common examples of function overloading are the unitary and binary operators on regular data types. The plus statement can operate on shorts, longs, floats, doubles and several other data types.

inheritance

The inheritance of member variables and member functions from the base classes from which a class is derived. The access rules for inheritence are controlled by the private, public and protected member declarations. Classes derived from multiple base classes lare refered to as having multiple inheritance.

linking

The process of turning a set of compiled object code sets into a single executable binary. The set of object files must include the declaration and definition of all variables and functions used by the program.

member variable

A variable that is a member of a class. Member variable access is controlled by the private, public and protected member declarations.

member function

A function that is a member of a class. Member function access is controlled by the private, public and protected member declarations.

object oriented programming

A programming philosophy that treats program elements as real world or abstract objects with interfaces that connect them. Object oriented programming promises code reusability, ease of development, and ease of maintenance. However, because of the multiple layers of encapsulation involved, object oriented programming does not produce the most efficient code possible.

pass-by-value

The default argument passing mechanism of C++ and C. Space is allocated for a copy of each function argument and the value of the argument is copied into the space when a function is called. Although pass-by-value prevents corruption of outside scoped arguments and prevents function side effects, it can be inefficient when large abstract data types such as classes are used.

pass-by-reference

An argument passing mechanism that only allocates space for a reference pointer to the function argument. Pass-by-reference does not require the copying of the function argument but will allow the modification of outside scoped arguments. When used with the const directive (const float&, pass-by-reference is equivalent to pass-by value and is an efficient argument passing mechanism for abstract data types such as classes.

pointer

A data type that holds a memory pointer to either a stack allocated or dynamically allocated program variable or function. A pointer can be de-referenced(->) to access a class member variable or call a class member function.

polymorphism

The property that a pointer to any member of a class can be dynamically re-cast as a pointer to any derived or parent class of that class. Polymorphism allows class pointers to act as generalized pointers that may actually refer to multiple different data types.

private member

A class member variable or function that may only be accessed from within a class. Private member variables and functions cannot be accessed from outside of the class or by sub-classes derived from a class.

protected member

A class member variable or function that may only be accessed from within a class or derived classes. Protected member variables and functions cannot be accessed from outside of the class.

public member

A class member variable or function that may by accessed from outside the class. Public member functions represent the public interface to the class and are an important ingredient in object oriented programming.

scope

The program area within which a variable is declared. All variables declared within a block are valid in the sub-blocks within that block unless they are overriden. Variables declared within a block are not valid outside of that block. Class member variables are useful for creating variables that exist within the scope of all member functions.

static member

A member variable or function that is not allocated dynamically when a class is created. All instances of a class will share the same memory allocted for a static member variable of function. Static member variables are often refered to a class variables. Static member functions are used when a class member function is passed to another function such as an OpenGL callback.

sub-class

A class derived from a base-class. A sub-class will inherit the member variables and functions of the parent class subject to the access rules of the parent class.

virtual function

A function that can be overriden by a derived class. The virtual directive is used to indicate that sub-classes my override the associated function.