Object Oriented Programming Quiz 4 12/6/2022
template function and classes
enable programs to work on many different data types without being rewritten for each one.
parameterize
templates provide the capability to ___________ types in functions and classes
define generic types for a class
generic types, concrete types
You can define functions or classes with __________ that can be substituted for ___________ by the compiler
default type
can assign a ________ for a type parameter
array limitation
The array size is fixed when the array is created
push back(): void
Appends the element in this vector
pop back(): void
Removes the last element from this vector
size(): unsigned const
Returns the number of elements in this vector
at(): elementType const
Returns the element at the specified index in this vector
empty() bool const
returns true if vector is empty
clear(): void
Removes all elements from this vector
swap(): void
Swaps the contents of this vector with the specified vector
operator overloading
Providing a user-defined meaning to a pre-defined operator (e.g., +, ==, <<) for a user-defined type (e.g., a class)
Defining functions for operators
Operators
Functions defined in a class
operator
These functions are named with keyword _________ followed by the actual operator.
Inheritance
Define new classes from existing classes
base class
a general class, not accessible outside the class
derived class
specialized class
accessor/mutator
base classes can be accessed through public _____ if defined in base class
constructor
The _________ of a derived class first calls its base class's constructor before it executes its own code.
destructor
The ______________ of a derived class executes its own code then automatically calls its base class's _____________.
derived
Constructors can only be called from the constructors of the _______ classes to initialize the data fields.
Constructor Chaining
Constructing an instance of a class invokes all the superclasses' constructors along the inheritance chain
Destructor Chaining
When an object of a derived class is destroyed the derived class destructor is called. Then it invokes the base class destructor
Inheritance Hierarchy
A set of hierarchical relationships between classes of objects
Redefining function
function in a derived class that has the same name and parameter list as a function in the base class
Overloading Functions
The functions have the same name but different parameter lists.
Redefining vs. Overloading
Overloading a function is a way to provide more than one function with the same name but with different signatures to distinguish them. To redefine a function, the function must be defined in the derived class using the same signature and the same return type as in its base class
Polymorphism
A variable of a supertype can refer to a subtype object.
Supertype
A generic entity that has a relationship with one or more subtypes
Subtype
A subgrouping of the entities in an entity type that is meaningful to the organization and that shares common attributes or relationships distinct from other subgroupings.
Inheritance Chain
A polymorphic function can be implemented in several classes along this
dynamic binding
type of object is not determined until run-time
two steps for dynamic binding
Function must be defined virtual in the base class
The variable that references the object must be passed by reference or passed as pointer in the virtual function