Chapter 13 Flashcards

1
Q

True or false:
In C++,&raquo_space; is used as a stream extraction operator and as a right shift operator.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or false:
Operator functions typically return void.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

True or false:
Operators can be overloaded either for objects of the user-defined types, or for a combination of objects of the user-defined type and objects of the built-in type.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

True or false:
In C++, operator is a reserved word.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

True or false:
A friend function does not have access to the private data members of the class.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

True or false:
The declaration of a friend function cannot be placed within the private part of the class.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

True or false:
When writing the definition of a friend function, the name of the class and the scope resolution operator precede the name of the friend function in the function heading.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

True or false:
Most operator functions can either be member functions or nonmember functions of a class.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

True or false:
Both parameters of the function to overload the operator &laquo_space;are reference parameters.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

True or false:
The associativity of the operator = is from right to left.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

The name of the function to overload the operator <= is _________.

A

operator<=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Every object of a class maintains a (hidden) pointer to itself, and the name of this pointer is _____.

A

this

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

When an object invokes a member function, the member function references the pointer ______ of the object.

A

this

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

A(n) _________ function is a nonmember function that has access to all members of the class.

A

friend

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

The function that overloads the ___ operator for a class must be declared as a member of the class.

A

->

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

The general form of the functions to overload the binary operators as member functions of a class is returnType operator#(_____ className& ) const;

A

const

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Which of the following function prototypes overloads the != operator for the class rectangleType?

A

bool operator!=(const rectangleType& ) const;

18
Q

The return type of the function operator == is _______.

A

bool

19
Q

To include the operator function operator+ as a nonmember function of the class rectangleType, its prototype in the definition of rectangleType is: ______ rectangleType operator+(const rectangleType& , const rectangleType& );

A

friend

20
Q

The general syntax to overload the stream extraction operator&raquo_space; for a class is:

A

friend istream& operator»(istream&, className&);

21
Q

The return type of the function to overload the operator&raquo_space; must be a reference to a(n) ______ object.

A

istream

22
Q

Which of the following is a built-in operation on classes?

A

assignment

23
Q

The general syntax for the function prototype to overload the assignment operator = for a class is________.

A

const className& operator=(const className& );

24
Q

To overload the pre-increment (++) operator for a class, if the operator function is a member of that class, it must have ___ parameter(s).

A

no

25
Q

Which of the following is the general syntax of the function prototype to overload the pre-increment operator ++ as a member function?

A

className operator++();

26
Q

Which of the following is the general syntax of the function prototype to overload the pre-increment operator as a nonmember function?

A

friend className operator++(className & );

27
Q

Which of the following is the general syntax of the function prototype to overload the post-increment operator as a member function?

A

className operator++(int);

28
Q

When the post-increment operator is overloaded as a nonmember function of the class, the operator function has ____ parameter(s).

A

two

29
Q

If you overload the binary arithmetic operator + as a member function, how many objects must be passed as parameters?

A

one

30
Q

Which of the following is the syntax to declare the operator function operator[] as a member function of a class for nonconstant arrays?

A

Type& operator;

31
Q

Which of the following is the syntax to declare the operator function operator[] as a member function of a class for constant arrays?

A

const Type& operator;

32
Q

Using the class template, you can write a single code segment for a set of related _______.

A

classes

33
Q

Class templates are called ______ types.

A

parameterized

34
Q

Suppose cType is a class template, and func is a member function of type cType. The heading of the function definition of func is:

A

template <class>
funcType cType<Type>::func(parameters)</Type></class>

35
Q

With the exception of the ___________ operator and the member selection operator, operators must be overloaded to be used on class objects.

A

assignment

36
Q

Any function that overloads an operator is called a(n) __________ function.

A

operator

37
Q

The operators that cannot be overloaded are ., .*, ::, ?:, and ______.

A

sizeof

38
Q

The only built-in operations on classes are assignment(=) and _____________.

A

member selection

39
Q

The ________ operator causes a member-wise copy of the member variables of the class.

A

assignment

40
Q

A(n) _________ constructor converts its argument to an object of the constructor’s class.

A

conversion