Inheritance Review, Chapter 13 object review, Ch 15 - C++
Members of a class object may be accessed through a pointer to the object by using the _________ operator.
The Arrow is the Pointer Operator -->
f
a member function of a derived class may not have the same name as a member function of the base class
a class is very similar to an ___
a structure
The base class access specification determines how __ members in the base class may be accessed by derived classes
a,b,c (private, public, protected
When a derived class has two or more base classes, the situation is known as
multiple inheritance
Arguments are passed to the base class destructor function by the __ class a __ function
none of these ( derived, constructor; derived, destructor;base,constructor; base,destructor)
The following statement allows the __ members of the Car class to access __ members of the Vehicle class. class Car: private Vehicle
none of these (private, private; public, private; protected, private; public, protected)
___ programming is centered around objects
object
A virtual function is a member function that expects to be __ in a derived class
overridden
A class may have more than one constructor, as long as each has a different _________.
parameter list
__ to a base class may be assigned the address of a derived class object
pointers
t
pointers to a base class may be assigned the address of a derived class object
The term __ means the ability to take many forms
polymorphism
When member functions behave differently, depending upon which object performed the call, this is an example of __
polymorphism
The default access specification of class members is ____
private
__ members of a base class are never accessible to a derived class
private
Protected members of a base class are like __, but they may be accessed by derived classes
private members
t
private members of a private base class become inaccessible to the derived class
___ programming is centered around functions or procedures
procedural
two common programming methods in practice today are
procedural programming, object-oriented programming
private
protected members of a base class are like __________ members, except they may be accessed by derived classes.
f
protected members of a private base class become public members of the derived class
t
protected members of a public base class become protected members of the derived class
The default access specification of a struct in C++ is _________.
public
t
public members of a private base class become private members of the derived class
f
public members of a protected base class become inaccessible to the derived class
Constructors cannot have a(n) _________ type.
return
Like constructors, destructors cannot have a(n) _________ type.
return
When the compiler binds a member function call with the version of the function that resides in the same class as the call itself, this is considered __ binding
static
f
the base class constructor is called after the derived class constructor
t
the base class destructor is called after the derived class destructor
f
the base class's access specification affects the way base class member functions may access base class member variables
t
the base class's access specification affects the way the derived class inherits members of the base class
A destructor has the same name as the class, but is preceded by a(n) _________ character.
tilde ~
.65. T F Constructors may have default arguments.
true
52. T F Class members are private by default.
true
54. T F Classes and structures in C++ are very similar.
true
57. T F It is legal to define a pointer to a class object.
true
58. T F You can use the new operator to dynamically allocate an instance of a class.
true
61. T F Constructors may not have a return type.
true
63. T F Destructors cannot take arguments.
true
66. T F Member functions may be overloaded.
true
68. T F A class may not have a constructor with no parameter list, and a constructor whose arguments all have default values.
true
69. T F A class may only have one destructor.
true
72. T F A class s responsibilities are the things the class is responsible for knowing, and actions the class must perform.
true
In the statement class car:public vehicle, which is the base class?
vehicle
A virtual function is declared by placing the keyword __ in front of the return type in the base class's function declaration
virtual
__ functions are dynamically bound by the compiler
virtual
A __ of a base class expects to be overridden in a derived class
virtual function
first
when both a base class and a derived class have constructors, the base class's constructor is called ________
last
when both a base class and a derived class have destructors, the base class's destructor is called _______
A contractor uses a blueprint to build a set of identical houses. Are classes analogous to the blueprint or the houses?
A class is analogous to the blueprint.
What are a class's responsibilities?
A class's responsibilities are the things that the class is responsible for knowing and the actions that the class is responsible for doing.
What is a mutator function? What is an accessor function?
A mutator stores a value in a private member variable or changes its value in some way; An Accessor retrieves a value from a private member variable and do not change an object's data, so marked const
51. T F Private members must be declared before public members.
False
55. T F All private members of a class must be declared together.
False
How do you identify the classes in a problem domain description?
Identify all the nouns and pronouns in the problem domain description. Each of these is a potential class. then refine the list to include only the classes that are relevant to the problem.
When a member function s body is written inside a class declaration, the function is _________.
Inline
Defining a class object is often called the _________ of a class.
Instantiation
When defining an array of class objects, how do you pass arguments to the constructor for each object in the array?
Item inventory[4] = { Item("Hammer", 8, 9), "Wrench", Item("Pliers") }; Where inventory[3] calls the default constructor.
members
a derived class inherits __________ of its base class
When you derive a class from an existing class, you __ add new data and functions
may
Polymorphism is when __ in a class hierarchy perform differently, depending upon which object performs the call
member functions
____ is an object's ability to contain and manipulate its own data
Encapsulation
The difference between a class and an instance of the class is ___
A class describes a data type. An instance of a class is an object of the data type that exists in memory.
If you were writing the external definitions of the Canine class s member functions, you would save them in a file named _________.
Canine.cpp
If you were writing the declaration of a class named Canine, what would you name the file it was stored in? _________
Canine.h
In the following statement which is the derived class? class Car: protected Vehicle
Car
What is a default constructor? Is it possible to have more than one default?
Constructor that takes no arguments; No you cannot have more than one
A(n) _________ constructor is one that requires no arguments.
Default
Is it possible to have more than one constructor? Destructor?
May have more than one as long as each has a different parameter list; Only one per class for destructor
What is a constructor? What is a deconstructor?
Member function that is automatically called when an object is created, constructs an object, function name is same as class name; same but when object is destroyed, name is ~className;
The difference between a structure and a class is ___
Members of a struct are public by default, while they are private by default in classes
The default access specification of class members is _________.
Private
In an inheritance situation, the new class that you create from an existing class is known as the
a and c (derived class, child class)
f
a base class may not be derived from another class
Can you think of a good reason to avoid writing statements in a class member function that use cout or cin?
They are global variables so you can't control when they are called
Under what circumstances should a member function be private?
When the function is necessary for internal processing, but not useful to the program outside the class. In some cases a class may contain member functions that initialize member variables or destroy their contents. Those functions should not be accessible by an external part of the program because they may be called at the wrong time.
Is it a good idea to make member variables private? Why or why not?
Yes it is. This protects the variables from being directly manipulated by code outside the class, and prevents them from receiving invalid data.
If a class object is dynamically allocated in memory, does its constructor execute? If so, when?
Yes, the constructor executes when the object is created.
The base class's __ affects the way its members are inherited by the derived class
access specification
an _____ is a key word inside a class declaration that establishes a member's accessibility
access specifier
Multiple inheritance opens the opportunity for a derived class to have __ members
ambiguous
t
arguments are passed to the base class constructor by the derived class constructor
In the following statement, what is being protected? class car: protected vehicle
base class members
The __ constructor is called before the __ constructor
base, derived
the ____ is the construct primarily used to create objects
class
. A(n) _________ is a member function with the same name as the class.
constructor
A(n) _________ is automatically called when an object is created.
constructor
A class may only have one default _________ and one _________.
constructor and deconstructor
_________ are useful for performing initialization or setup routines in a class object.
constructors
A constructor whose arguments all have default values is a(n) _________ constructor.
default
The __ destructor is called before the __ destructor
derived, base
Multiple inheritance is when a __ class has __ base classes
derived, two or more
A(n) _________ is a member function that is automatically called when an object is destroyed.
destructor
The compiler performs __on virtual functions
dynamic binding
.53. T F Members of a struct are private by default.
false
56. T F All public members of a class must be declared together.
false
59. T F A private member function may be called from a statement outside the class, as long as the statement is in the same program as the class declaration.
false
60. T F Constructors do not have to have the same name as the class.
false
62. T F Constructors cannot take arguments.
false
64. T F Destructors may return a value.
false
67. T F Constructors may not be overloaded.
false
70. T F When an array of objects is defined, the constructor is only called for the first element.
false
71. T F To find the classes needed for an object-oriented application, you identify all of the verbs in a description of the problem domain.
false
void Circle::getRadius() The name of the function is ____
getRadius
__ allows us to create new classes based on existing classes
inheritance
__ is commonly used to extend a class, or to give it additional capabilities
inheritance
A(n) _________ may be used to pass arguments to the constructors of elements in an object array.
initialization
f
it isn't possible for a base class to have more than one constructor