COSC 1408 Chapter 14
True/False: A static member variable can be used when there are no objects of the class in existence.
True
True/False: It is possible to declare an entire class as a friend of another class.
True
True/False: If you overload the prefix ++ operator, the postfix ++ operator is automatically overloaded.
False
True/False: A non-static member function may not access a static member variable.
False
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.
True
True/False: The this pointer is automatically passed to non-static member functions of a class.
True
True/False: When you overload an operator, you can change the operator's original meaning to something entirely different.
True
This operator may be used to assign one object to another. (a) = (b) == (c) <> (d) @ (e) None of these
(a) =
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
(a) static
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
(b) copy constructor
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
(b) member variables
To overload the + operator, you would write a function named ________. (a) overload + (b) operator + (c) function + (d) operator.overload(+) (e) None of these
(b) operator +
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
(b) overloaded assignment operator
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
(b) this pointer
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
(b) work in its usual way, but with programmer-defined data types
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
(c) constant, const
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
(c) copy constructor
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
(c) dummy parameter
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
(c) forward declaration
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
(c) has a
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
(c) object composition
An ________ operator can work with programmer-defined data types. (a) inline (b) unconditional (c) overloaded (d) undefined (e) None of these
(c) overloaded
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
(c) overloaded
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
(c) square brackets [ ] operator
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
(c) standard operators
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
(c) static
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
(d) all of these
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
(d) friend
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
(d) operands
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
(d) reference object
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
(d) static
True/False: A public data member may be declared a friend of a private function.
False
True/False: C++ permits you to overload the sizeof operator and the this pointer.
False
True/False: In C++, if you overload the < operator, you must also overload the > operator.
False
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.
False
True/False: When you overload the << operator, you must also overload the >> operator.
False
True/False: You can overload the conditional operator to make it function as an unconditional operator.
False
True/False: You may overload any C++ operator, and you may use the operator function to define non-standard operators, such as @ and ^.
False
True/False: A static member function does not need to be called by a specific object of the class.
True
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.
True