Complete Solutions
11.1 - What is the difference between an instance member
variable and a static member variable? Correct Answers each
class object (an instance of a class) has its own copy of the class'
instance member variables. if a class's member is static, only
one copy of the variable exists in memory. all objects of that
class have access to that one variable.
11.10 - Describe a situation in which memberwise assignment
should not be used. Correct Answers when an object contains
a pointer to dynamically allocated memory.
11.11 - When is a copy constructor called? Correct Answers
when an object is initialized with another object's data, when an
object is passed by value as the argument to a function, and
when an object is returned by value.
11.12 - How does the compiler know that a member function is
a copy constructor? Correct Answers the member function has
the same name as the class, has no return type, and has a single
reference parameter to the same type as the class
11.13 - What action is performed by a class' default copy
constructor? Correct Answers it performs memberwise
assignment
11.15 - rewrite the following statement so it appears in function
call notation
, dog = cat Correct Answers dog.operator=(cat)
11.16 - What is the disadvantage of an overloaded = operator
returning void? Correct Answers it cannot be used in multiple
assignment statements or other expressions.
11.17 - Describe the purpose of the "this" pointer. Correct
Answers it's a built-in pointer, available to a class's instance
member functions, that always points to the instance of the class
making the function call.
11.18 - The "this" pointer is automatically passed to what type
of functions? Correct Answers Instance member functions
11.19 - Assume a class named animal which overloads = and +.
wildcat = cat + tiger
of the three objects, which is calling the operator + function?
Which object is passed as an argument into the function?
Correct Answers cat is calling the + function. tiger is passed as
an argument.
11.2 - Static member variables are declared inside the class
declaration. Where are the static member variables defined?
Correct Answers outside the class declaration
11.20 - What does the use of a dummy parameter in a unary
operator function indicate to the compiler? Correct Answers
the operator is used in postfix mode
*** what is postfix mode?