More About Classes Gaddis Chapter 14 Test Bank Docx - Test Bank | C++ Control Structures 9e by Tony Gaddis. DOCX document preview.

More About Classes Gaddis Chapter 14 Test Bank Docx

Starting Out with C++ from Control Structures to Objects, 9e (Gaddis)

Chapter 14 More about Classes

TRUE/FALSE

1. 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.

2. When you overload an operator, you can change the operator's original meaning to something entirely different.

3. By default, when an object is assigned to another object, each member of one object is copied to its counterpart in the other object.

4. The overloaded = operator copies data from one object to another so it is known as the overload copy operator.

5. If you overload the prefix ++ operator, the postfix ++ operator is automatically overloaded.

6. C++ permits you to overload the sizeof operator and the this pointer.

7. When you overload the << operator you must also overload the >> operator.

8. A public data member may be declared a friend of a private function.

9. A static member variable can be used when there are no objects of the class in existence.

10. You can overload the conditional operator to make it function as an unconditional operator.

11. You may overload any C++ operator and you may use the operator function to define non-standard operations, such as @ or ^.

12. In C++ if you overload the < operator, you must also overload the > operator.

13. A static member function does not need to be called by a specific object of the class.

14. It is possible to declare an entire class as a friend of another class.

15. An aggregate class's constructor can use a member initialization list to call the constructors for each of its member objects.

16. The this pointer is a special built-in pointer that is automatically passed as a hidden argument to all non-static member functions.

17. A non-static member function may not access a static member variable.

18. A move operation transfers resources from a source object to a target object.

19. In C++11 an rvalue reference is a reference variable that can refer only to temporary objects.

MULTIPLE CHOICE

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. Which of the following operators may be used to assign one object to another?

a.

=

b.

==

c.

<>

d.

@

e.

None of these

8. 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

9. 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

10. 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

11. 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

12. 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

13. 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

14. 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

15. 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

16. 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

17. 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

18. To overload the + operator, you would write a function named

a.

overload +

b.

operator +

c.

function +

d.

operator.overload(+)

e.

None of these

19. 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

20. An ___________ operator can work with programmer-defined data types.

a.

inline

b.

unconditional

c.

overloaded

d.

undefined

e.

None of these

21. 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

22. 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

23. 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

24. 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

25. 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

26. 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

MULTIPLE RESPONSE

1. 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

Document Information

Document Type:
DOCX
Chapter Number:
14
Created Date:
Aug 21, 2025
Chapter Name:
Chapter 14 More About Classes
Author:
Tony Gaddis

Connected Book

Test Bank | C++ Control Structures 9e

By Tony Gaddis

Test Bank General
View Product →

$24.99

100% satisfaction guarantee

Buy Full Test Bank

Benefits

Immediately available after payment
Answers are available after payment
ZIP file includes all related files
Files are in Word format (DOCX)
Check the description to see the contents of each ZIP file
We do not share your information with any third party