Você está na página 1de 4

Class Polymorphism 1 Kelly Boan

Names: Andy Bui

Fill in the Blank: Write the terms from this Word Bank to complete the sentences for #1-13 in the gold boxes.

abstract base class dynamic members polymorphism scope resolution


accessor first middle pure dynamic single inheritance
base class version function multiple inheritance pure static static
center last override or redefine pure virtual virtual
chain link overrides, virtual real

A derived class inherits the members of its base class.

When both a base class and a derived class have constructors, the base classs constructor is called
first (first/last).

When both a base class and a derived class have destructors, the base classs constructor is called last
(first/last).

An overridden base class function may be called by a function in a derived class by using the scope
resolution
operator.

When a derived class redefines a function in a base class, which version of the function do objects that are
defined of the base class call? base class version

A(n) virtual member function in a base class expects to be overridden in a derived class.

static binding is when the compiler binds member function calls at compile time.

dynamic binding is when a function call is bound at runtime.

polymorphism is when member functions in a class hierarchy behave differently, depending upon which
object performs the call.

When a pointer to a base class is made to point to a derived class, the pointer ignores any Overriding ,
virtual
the derived class performs, unless the function is

A(n) Abstract base class cannot be instantiated.

A(n) Pure Virtual function has no body, or definition, in the class in which it is declared.

A(n) chain of inheritance is where one class is derived from a second class,
which in turn is derived from a third class.

multiple inheritance is where a derived class has two or more base classes.

In multiple inheritance, the derived class should always override or redefine


a function that has the same name in more than one base class.
Complete this table with private, protected, public, inaccessible

In a private base class, this base class MEMBER access ...becomes this access specification in the derived class
specification
private inaccessible
protected private
public private

In a protected base class, this base class MEMBER access ...becomes this access specification in the derived class
specification
private inaccessible
protected protected
public protected

In a public base class, this base class MEMBER access ...becomes this access specification in the derived class
specification
private inaccessible
protected protected
public public

True or False: Determine whether each statement is true or false in the green box. If false, rewrite the
statement to make it true in the gold box

false Example) The class interface is synonymous with class implementation


The class interface is synonymous with the class declaration

The base class s access specification affects the way base class member functions
false
may access base class member variables.
The base class s access specification affects the way the derived class member functions
may access the base class member variable

The base class s access specification affects the way the derived class inherits
true
members of the base class.

true Private members of a private base class become inaccessible to the derived class.

Public members of a private base class become private members of the


true
derived class.

Protected members of a private base class become public members of the


false
derived class
Protected members of a private base class become private members of the
derived class

Public members of a protected base class become private members of the


false
derived class.
Public members of a protected base class become protected members of the
derived class
Private members of a protected base class become inaccessible to the
true
derived class.

Protected members of a public base class become public members of the


false
derived class.
Protected members of a public base class become protected members of the
derived class.

false The base class constructor is called after the derived class constructor.
The base class constructor is called before the derived class constructor

true The base class destructor is called after the derived class destructor.

false It isnt possible for a base class to have more than one constructor.
It is possible for a base class to have more than one constructor.

Arguments are passed to the base class constructor by the derived class
true
constructor.

A member function of a derived class may not have the same name as a
false
member function of the base class.
A member function of a derived class may have the same name as a
member function of the base class.

true Pointers to a base class may be assigned the address of a derived class object.

false A base class may not be derived from another class.


A base class may be derived from another class

Examine the following classes. The table lists the variables that are members of the Third class (some are
inherited). Complete the table by filling in the access specification each member will have in the Third class.
Write ''inaccessible'' if a member is inaccessible to the Third class.

Member
Access Specification in Third class
Variable
a inaccessible
b protected
c protected
d inaccessible
e protected
f public
g Private
h Protected
i public

Você também pode gostar