C++ Glossary
Here are some important OOP/C++ terms:
-
abstract class:
a class with at least one
pure virtual method
is called abstract, meaning it cannot be instantiated.
-
assignment operator:
overriding the assignment operator for a class changes what
= does when used with members of
that class.
-
base class:
a class that another class inherits from.
-
big 3:
the main three elements of copy control: the assignment
operator, the copy constructor, and the destructor.
-
class:
a C++ construct that can hold both data values and
functions (called methods). It differs from a
struct in that the members of a struct are public by
default, while members of a class are private by default.
In practice, coders most often use
struct
when they don't intend to write any methods.
-
compile:
turning source code into machine code.
-
constructor:
the class method that initializes an object of that class.
-
copy constructor:
the class method that initializes an object of that class
when it is being copied from another instance of that
class.
-
delegation:
giving programming tasks to the lowest-level object that can
handle them. For example, if your Department class needs to print Employee objects, it delegates the task
to the Employee class, rather than
containing code to print them itself.
-
dereference:
to use a pointer to get at the value of what it points to.
-
derived class:
a class that inherits from another class.
-
destructor:
the class method that cleans up all dynamically allocated
resources for an object of that class.
-
dynamic binding:
means that the language being used
decides what method should be called in a particular case at
runtime, rather than at compile time.
(See polymorphism.)
-
dynamic memory:
means that the language being used
decides what method should be called in a particular case at
runtime, rather than at compile time.
(See polymorphism.)
-
exception:
a C++ error-handling technique that enables non-local transfers
of control.
-
explicit:
a C++ keyword that turns off implicit use of some type
conversion.
-
function:
A "chunk" of executable code that is (typically) given a name
and can be invoked (called) from many places.
-
function prototype:
code that just shows the return type, parameter types,
and const status of a function,
but does not include the body of the function (what it actually
does).
-
functor:
an object designed to work like a function. In C++, this
is achieved by overloading the ()
operator.
-
generic programming:
focuses on the creation of data structures and algorithms that
can work with many different types. In C++, generic programming
is supported by templates.
-
heap:
the area of memory under the direct control of the application.
Python manages the heap for the programmer, while C++ gives
the programmer direct control over heap allocation.
-
keyword:
one of a number of reserved strings in a language, that can't
be used to name functions or variables. In C++, keywords
include things like
if,
while,
for,
const,
virtual,
and many more.
-
lambda:
an anonymous function, also called a lexical closure.
-
linker:
The program that pulls together several compiled files into a
single, executable file.
-
log file:
A place where a program with no interactive user can note
errors or other actions taking place.
-
LSP (Liskov Substitution Principle):
One should be able to substitute an instance of a derived
class wherever an instance of a base class is called for.
-
memo-ization:
storing results in
some data structure rather than calculating them again and
again.
-
multiple inheritance:
when a derived class inherits from more than one base class.
-
NaN:
a floating point value meaning the result of some calculation
is "Not a Number": see
NaN.
-
overloading:
to create more than one function or operator with
the same name, but a different type signature.
For instance, +
can add two integers, but it can also
add two doubles or two strings.
-
overriding:
is to create a method in a derived class that replaces the
behavior of a method with the same name and arguments
in its parent class.
-
pass-by-reference:
a way of passing an argument to a function that gives the
function direct access to the object being passed.
-
pass-by-value:
passing an argument to a function by copying the object
used and handing the funciton only a copy of its value, not
access to the original object.
-
pointer:
a variable that holds a memory address.
In C++, pointers are typed.
-
polymorphism:
also called "dynamic binding." Polymorphism describes the
ability, present in some languages, to accept a pointer or
reference to a base-type object, and yet successfully invoke
the proper method in a derived-class object being referenced.
In C++, polymorphism can be turned on by using the reserved
word virtual on a method in a class.
-
preprocessor:
the program that runs before the compiler and handles
#include and
#define directives.
-
pure virtual method:
a method with the "body" = 0,
used to indicate that only descendants that supply that
method can actually be created.
-
ranged for loop:
similar to Python's for-each loop.
It iterates through each element of a
collection without any explicit indexing.
-
reference:
a "smarter" pointer-like object that is de-referenced each time
it is used.
More
on C++ references.
-
slicing:
what occurs when an instance of derived class B is
assigned to a variable of base class A. The data members of B
that are not in A get "sliced" off.
-
stack:
the area of memory managed by the run-time system.
New "stack frames" are pushed onto the stack each time
a new function call is made, and they include space for the
function's parameters, local variables, and its return
value.
-
static binding:
decides what method should be called in a particular case when
compiling, rather than at runtime.
-
static typing:
the assignment of a type to a variable once, at compile time,
rather than dynamically, at run time.
-
Standard Template Library (STL):
A collection of templatized collections and algorithms
that come with every C++ implementation.
-
string:
The C++ type that holds text.
-
struct:
A C++ construct that can hold both data values and
functions (called methods). It differs from a
class in that the members of a struct are public by
default. In practice, coders most often use
struct
when they don't intend to write any methods.
-
structured programming:
a programming concept that suggests the clarity and reliability
of programs can be enhanced by relying on control-flow managers
such as if statements and while loops.
-
template:
a machine that produces classes or functions
when passed a concrete type. It enables C++ support
for generic programming.
-
vector:
in C++, a class in the Standard Template Library
that allows random, constant-time access to a collection of
items of some specific type, and holds those items in a
determinate order.
-
virtual:
in C++, this keyword turns on
polymorphism
.