CH 13 CSCI

¡Supera tus tareas y exámenes ahora con Quizwiz!

A(n) ____ function is a nonmember function that has access to all members of the class. a. friend b. access c. void d. protected

a

Suppose cType is a class template, and func is a member function of cType. The heading of the function definition of func is: ____. a. template <class Type> funcType cType<Type>::func(parameters) b. template <class Type> funcType cType<Type> c. template <class Type> funcType cType<Type> == func(parameters) d. template <class Type> funcType cType<Type>func(parameters;

a

Suppose cType is a class template, which can take int as a parameter. The statement: ____ declares x to be an object of type cType, and the type passed to the class cType is int. a. cType<int> x; b. cType int x; c. cType int = x; d. cType int :: x;

a

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 b. double c. bool d. int

a

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 b. one c. two d. three

a

Which of the following function prototypes overloads the != operator for the class rectangleType? a. bool operator!=(const rectangleType&) const; b. int operator!=(const rectangleType) const; c. bool operator!=(rectangle&) const; d. int operator!=(rectangle&) const;

a

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++(); b. className operator++(int); c. friend className operator++(); d. friend className operator++(int);

a

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[](int index) const; b. const Type& []operator(int index) const; c. const Type& operator[](int index); d. const Type [](int index) const;

a

If you overload the binary arithmetic operator + as a member function, how many objects must be passed as parameters? a. none b. one c. two d. three

b

If you overload the binary arithmetic operator + as a member function, how many objects must be passed as parameters? a. none b. one c. two d. three

b

The general form of the functions to overload the binary operators as member functions of a class is returnType operator#(____ className&) const; a. class b. const c. * d.

b

The return type of the function operator == is ____. a. int b. bool c. char d. void

b

The return type of the function to overload the operator >> must be a reference to a(n) ____ object. a. iostream b. istream c. ostream d. stream

b

Which of the following is a built-in operation on classes? a. increment b. assignment c. decrement d. relational

b

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(int index) const; b. const Type& operator[](int index) const; c. const Type& operator[](int index); d. const Type [](int index) const;

b

A(n) ____ function is a nonmember function that has access to all members of the class. a. access b. protected c. friend d. void

c

Suppose cType is a class template, and func is a member function of cType . The heading of the function definition of func is: ____. a. template <class Type> funcType cType<Type> == func(parameters) b. template <class Type> funcType cType<Type> c. template <class Type> funcType cType<Type>::func(parameters) d. template <class Type> funcType cType<Type>func(parameters;

c

The function that overloads the ____ operator for a class must be declared as a member of the class. a. :: b. * c. -> d. +

c

The general syntax for the function prototype to overload the assignment operator = for a class is ____. a. friend className& operator=(const className&); b. string className& operator=(className&); c. const className& operator=(const className&); d. className& operator=(className&);

c

(T/F) 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.

false

(T/F) A friend function is a nonmember of a class

true

(T/F) An operator that has different meanings with different data types is said to be overloaded.

true

(T/F) Both parameters of the function to overload the operator << are reference parameters

true

(T/F) Except for the assignment operator and the member selection operator, to use an operator on class objects, that operator must be overloaded. The assignment operator performs a default member-wise copy

true

(T/F) For classes with pointer member variables, the assignment operator must be explicitly overloaded

true

(T/F) If an operator function is a member of a class, the far left operand of the operator must be a class object (or a reference to a class object) of that operator's class

true

(T/F) In C++, >> is used as a stream extraction operator and as a right shift operator.

true

(T/F) In c++, friend is a reserved word

true

(T/F) Most C++ operators can be overloaded

true

(T/F) Most operator functions can either be member functions or nonmember functions of a class.

true

(T/F) Operator functions are value-returning functions.

true

(T/F) Operator overloading provides the same concise notation for user-defined data types as is available for built-in data types

true

(T/F) 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.

true

(T/F) The associativity of the operator = is from right to left.

true

(T/F) The heading of the prototype of a friend function is preceded by the word friend

true

(T/F) The operator functions that overload the operators (), [], ->, or = for a class must be members of that class

true

(T/F) The operators that cannot be overloaded are ., .*, ::, ?:, and sizeof

true

(T/F) The pointer this refers to the object as a whole

true

(T/F) Any function that overloads an operator is called an operator function.

True

(T/F) In C++, operator is a reserved word

True

(T/F) It is not possible to create new operators. Only existing operators can be overloaded

True

(T/F) The syntax of the heading of the operator function is: returnType operator operatorSymbol(parameters)

True

The general syntax to overload the stream extraction operator >> for a class is ____. a. friend operator>>(istream&, className&); b. const istream& operator>>(istream&, className&); c. friend istream& operator>>(istream&, className&); d. istream& operator>>(istream&, className&);

c

Using a class template, you can write a single code segment for a set of related ____. a. operators b. constructors c. classes d. functions

c

When an object invokes a member function, the member function references the pointer ____ of the object. a. address b. it c. this d. object

c

When an object invokes a member function, the member function references the pointer ____ of the object. a. object b. it c. this d. address

c

When the post-increment operator is overloaded as a nonmember function of the class, the operator function has ____ parameter(s). a. no b. one c. two d. three

c

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++(); b. friend className operator++(); c. className operator++(int); d. friend className operator++(int);

c

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[](int index); b. Type& []operator(int index); c. Type& operator[](int index); d. Type [](int index);

c

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(int index); b. Type operator[](int index); c. Type& operator[](int index); d. Type [](int index);

c

Class templates are called ____ types. a. polymorphic b. structured c. member d. parameterized

d

Every object of a class maintains a (hidden) pointer to itself, and the name of this pointer is ____. a. self b. object c. it d. this

d

The name of the function to overload the operator <= is ____. a. overload<= b. <=operator c. <=new d. operator<=

d

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++(int); b. friend className operator++(int); c. friend className operator++(); d. className operator++();

d

Which of the following is the general syntax of the function prototype to overload the pre-increment operator as a nonmember function? a. className operator++(); b. friend className operator++(); c. className operator++(int); d. friend className operator++(className&);

d

(T/F) A friend function does not have access to the private data members of the class .

false

(T/F) A friend function does not have access to the private data members of the class.

false

(T/F) Operator functions typically return void.

false

(T/F) The declaration of a friend function cannot be placed within the private part of the class

false

(T/F) The declaration of a friend function cannot be placed within the private part of the class.

false


Conjuntos de estudio relacionados

Chapter 31: Concepts of Care for Patients With Dysrhythmias

View Set

Chapter 4 - Behavior Therapy and Integrated Psychopharmacology

View Set

Economics- Chapter 21- Protectionism

View Set

CSET S1 (World History Constructed Response)

View Set