COSC 1408 Chapter 14

25 July 2022
4.7 (114 reviews)
40 test answers

Unlock all answers in this set

Unlock answers (36)
question
Each object of a class has its own copy of the class's ________. (a) member functions (b) member variables (c) constructor and destructor functions (d) All of these (e) None of these
answer
(b) member variables
question
This type of member variable may be accessed before any objects of the class have been created. (a) private (b) public (c) inline (d) static (e) None of these
answer
(d) static
question
This operator may be used to assign one object to another. (a) = (b) == (c) <> (d) @ (e) None of these
answer
(a) =
question
C++ requires that a copy constructor's parameter be a(n) ________. (a) integer data type (b) floating point data type (c) pointer variable (d) reference object (e) None of these
answer
(d) reference object
question
C++ allows you to redefine the way ________ work when used with class objects. (a) compiler errors (b) preprocessor directives (c) standard operators (d) undefined variables (e) None of these
answer
(c) standard operators
question
When objects contain pointers, it is a good idea to create an explicit ________ function. (a) destructor (b) copy constructor (c) static constructor (d) inline constructor (e) None of these
answer
(b) copy constructor
question
A good reason for overloading an operator is to enable it to ________. (a) outperform its C language counterparts (b) work in its usual way, but with programmer-defined data types (c) operate on more operands than in its standard definition (d) operate on no operands (e) None of these
answer
(b) work in its usual way, but with programmer-defined data types
question
When a class contains an instance of another class, it is known as ________. (a) object overloading (b) operator overloading (c) object composition (d) dynamic composition (e) None of these
answer
(c) object composition
question
If you do not furnish one of these, an automatic memberwise copy will be performed when one object is assigned to another object. (a) overloaded constructor function (b) overloaded assignment operator (c) default constructor function (d) overloaded copy operator (e) None of these
answer
(b) overloaded assignment operator
question
It is a good idea to make a copy constructor's parameters ________ by specifying the ________ key word in the parameter list. (a) inline, inline (b) static, static (c) constant, const (d) global, global (e) None of these
answer
(c) constant, const
question
A reason to overload the ________ is to write classes that have array-like behaviors. (a) parentheses ( ) operator (b) curly braces { } operator (c) square brackets [ ] operator (d) colon : : operator (e) None of these
answer
(c) square brackets [ ] operator
question
If a member variable is declared ________, all objects of that class have access to that variable. (a) static (b) dynamic (c) inline (d) default (e) None of these
answer
(a) static
question
A member function that is declared ________ may not access any non-static data members in the class. (a) private (b) public (c) static (d) inline (e) None of these
answer
(c) static
question
This type of function is not a member of a class, but it has access to the private members of the class. (a) static (b) constructor (c) destructor (d) friend (e) None of these
answer
(d) friend
question
This is a special function that is called whenever a new object is created and initialized with another object's data. (a) destructor (b) static function (c) copy constructor (d) assignment function (e) None of these
answer
(c) copy constructor
question
If you do not furnish one of these a default will be provided for you by the compiler. (a) copy constructor (b) constructor (c) destructor (d) All of these (e) None of these
answer
(d) all of these
question
When you redefine the way a standard operator works when it is used with class objects, you have ________ the operator. (a) reassigned (b) reformatted (c) overloaded (d) overwhelmed (e) None of these
answer
(c) overloaded
question
To overload the + operator, you would write a function named ________. (a) overload + (b) operator + (c) function + (d) operator.overload(+) (e) None of these
answer
(b) operator +
question
This is a special built-in pointer that is available to a class's member functions. (a) overloaded -> operator (b) this pointer (c) &constructor pointer (d) ~destructor *ptr (d) None of these
answer
(b) this pointer
question
Object composition is useful for creating this type of relationship between classes. (a) friend (b) static (c) has a (d) conditional (e) None of these
answer
(c) has a
question
An ________ operator can work with programmer-defined data types. (a) inline (b) unconditional (c) overloaded (d) undefined (e) None of these
answer
(c) overloaded
question
When you overload an operator, you cannot change the number of ________ taken by the operator. (a) arguments (b) parameters (c) operations (d) operands (e) None of these
answer
(d) operands
question
A(n) ________ informs the compiler that a class will be declared later in the program. (a) static function (b) private data member (c) forward declaration (d) object conversion (e) None of these
answer
(c) forward declaration
question
In the following function header: FeetInches FeetInches : : operator++(int) the word (int) is known as a(n): (a) parameterless data type (b) incomplete argument (c) dummy parameter (d) incomplete parameter (e) None of these
answer
(c) dummy parameter
question
True/False: When a class declares an entire class as its friend, the friendship status is reciprocal. That is, each class's member functions have free access to the other's private members.
answer
False
question
True/False: By default, when an object is assigned to another, each member of one object is copied to its counterpart in the other object.
answer
True
question
True/False: When you overload an operator, you can change the operator's original meaning to something entirely different.
answer
True
question
True/False: If you overload the prefix ++ operator, the postfix ++ operator is automatically overloaded.
answer
False
question
True/False: A public data member may be declared a friend of a private function.
answer
False
question
True/False: C++ permits you to overload the sizeof operator and the this pointer.
answer
False
question
True/False: A static member variable can be used when there are no objects of the class in existence.
answer
True
question
True/False: When you overload the << operator, you must also overload the >> operator.
answer
False
question
True/False: You can overload the conditional operator to make it function as an unconditional operator.
answer
False
question
True/False: A static member function does not need to be called by a specific object of the class.
answer
True
question
True/False: It is possible to declare an entire class as a friend of another class.
answer
True
question
True/False: You may overload any C++ operator, and you may use the operator function to define non-standard operators, such as @ and ^.
answer
False
question
True/False: The this pointer is a special built-in pointer that is automatically passed as a hidden argument to all non-static member functions.
answer
True
question
True/False: In C++, if you overload the < operator, you must also overload the > operator.
answer
False
question
True/False: A non-static member function may not access a static member variable.
answer
False
question
True/False: The this pointer is automatically passed to non-static member functions of a class.
answer
True