Deck 14: More About Classes
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/46
Play
Full screen (f)
Deck 14: More About Classes
1
A non-static member function may not access a static member variable.
False
2
The this pointer is a special built-in pointer that is automatically passed as a hidden argument to all non-static member functions.
True
3
An aggregate class's constructor can use a member initialization list to call the constructors for each of its member objects.
True
4
In C++ if you overload the < operator, you must also overload the > operator.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
5
By default, when an object is assigned to another object, each member of one object is copied to its counterpart in the other object.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
6
C++ permits you to overload the sizeof operator and the this pointer.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
7
A public data member may be declared a friend of a private function.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
8
When you overload an operator, you can change the operator's original meaning to something entirely different.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
9
In C++11 an rvalue reference is a reference variable that can refer only to temporary objects.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
10
It is possible to declare an entire class as a friend of another class.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
11
You may overload any C++ operator and you may use the operator function to define non-standard operations, such as @ or ^.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
12
A static member variable can be used when there are no objects of the class in existence.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
13
A static member function does not need to be called by a specific object of the class.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
14
You can overload the conditional operator to make it function as an unconditional operator.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
15
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
A) member functions
B) member variables
C) constructor and destructor functions
D) All of these
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
16
When you overload the << operator you must also overload the >> operator.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
17
A move operation transfers resources from a source object to a target object.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
18
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.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
19
If you overload the prefix ++ operator, the postfix ++ operator is automatically overloaded.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
20
The overloaded = operator copies data from one object to another so it is known as the overload copy operator.
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
21
A good reason to overload 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
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
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
22
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
A) destructor
B) copy constructor
C) static constructor
D) inline constructor
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
23
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
A) compiler errors
B) preprocessor directives
C) standard operators
D) undefined variables
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
24
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
A) integer data type
B) floating-point data type
C) pointer variable
D) reference object
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
25
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) referenced
E) None of these
A) reassigned
B) reformatted
C) overloaded
D) referenced
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
26
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
A) inline, inline
B) static, static
C) constant, const
D) global, global
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
27
To overload the + operator, you would write a function named
A) overload +
B) operator +
C) function +
D) operator.overload(+)
E) None of these
A) overload +
B) operator +
C) function +
D) operator.overload(+)
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
28
An ___________ operator can work with programmer-defined data types.
A) inline
B) unconditional
C) overloaded
D) undefined
E) None of these
A) inline
B) unconditional
C) overloaded
D) undefined
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
29
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
A) arguments
B) parameters
C) operations
D) operands
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
30
A(n) __________ is a special function that is called whenever a new object is created and initialized with another object's data.
A) static function
B) destructor
C) copy constructor
D) assignment function
E) None of these
A) static function
B) destructor
C) copy constructor
D) assignment function
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
31
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
A) private
B) public
C) static
D) inline
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
32
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
A) object overloading
B) operator overloading
C) object composition
D) dynamic composition
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
33
Which of the following operators may be used to assign one object to another?
A) =
B) ==
C) <>
D) @
E) None of these
A) =
B) ==
C) <>
D) @
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
34
If you do not furnish a(n) __________, 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
A) overloaded constructor function
B) overloaded assignment operator
C) default constructor function
D) overloaded copy operator
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
35
The __________ 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
A) private
B) public
C) inline
D) static
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
36
A reason to overload the __________ is to allow you 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
A) parentheses ( ) operator
B) curly braces { } operator
C) square brackets [ ] operator
D) colon :: operator
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
37
If a member 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
B) dynamic
C) inline
D) default
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
38
Which type of function is not a member of a class but has access to the private members of the class?
A) static
B) constructor
C) destructor
D) friend
E) None of these
A) static
B) constructor
C) destructor
D) friend
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
39
A(n) __________ is a special built-in pointer that is available to a class's member functions..
A) this pointer
B) &constructor pointer
C) ~destructor *ptr
D) overload operator, ->
E) None of these
A) this pointer
B) &constructor pointer
C) ~destructor *ptr
D) overload operator, ->
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
40
If you do not furnish a __________, a default one will be provided by the compiler.
A) constructor
B) destructor
C) copy constructor
D) All of these
E) None of these
A) constructor
B) destructor
C) copy constructor
D) All of these
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
41
In C++11 reference variables that can refer only to temporary objects that would otherwise have no name are called __________ and are declared with a __________.
A) rvalues, ampersand (&)
B) lvalues, ampersand (&)
C) lvalues, double ampersand (&&)
D) rvalues, double ampersand (&&)
E) None of these
A) rvalues, ampersand (&)
B) lvalues, ampersand (&)
C) lvalues, double ampersand (&&)
D) rvalues, double ampersand (&&)
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
42
In the following function header, the word int is known as a(n) __________. FeetInches FeetInches:
:
Operator++(int)
A) parameterless data type
B) incomplete argument
C) dummy parameter
D) incomplete parameter
E) None of these
:
Operator++(int)
A) parameterless data type
B) incomplete argument
C) dummy parameter
D) incomplete parameter
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
43
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
A) static function
B) private data member
C) forward declaration
D) object conversion
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
44
Select all that apply. Given the following code fragment, which of the things shown below happen when the statement on line 8 executes?
1 int square(int a)
2 {
3 return a * a;
4 }
5 int main()
6 {
7 int x = 0;
8 x = square(5);
9 cout << x << endl;
10 return 0;
11 }
A) The square function is called and the value 5 is passed as an argument.
B) The square function calculates 5*5 and stores the result, 25, as a temporary value.
C) The temporary value is copied (assigned) to the variable x.
D) The temporary value is discarded by the system.
E) None of these
1 int square(int a)
2 {
3 return a * a;
4 }
5 int main()
6 {
7 int x = 0;
8 x = square(5);
9 cout << x << endl;
10 return 0;
11 }
A) The square function is called and the value 5 is passed as an argument.
B) The square function calculates 5*5 and stores the result, 25, as a temporary value.
C) The temporary value is copied (assigned) to the variable x.
D) The temporary value is discarded by the system.
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
45
In C++11 the __________ operator swaps the members of the object being assigned with the temporary object.
A) move assignment
B) swap assignment
C) temp assignment
D) semantic assignment
E) None of these
A) move assignment
B) swap assignment
C) temp assignment
D) semantic assignment
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck
46
In C++11 values that persist beyond the statement that created them and have names that make them accessible to other statements in the program are called
A) rvalues
B) lvalues
C) temporary values
D) semantics
E) None of these
A) rvalues
B) lvalues
C) temporary values
D) semantics
E) None of these
Unlock Deck
Unlock for access to all 46 flashcards in this deck.
Unlock Deck
k this deck