Filters
Question type

Study Flashcards

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;

E) B) and C)
F) C) and D)

Correct Answer

verifed

verified

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


A) access
B) protected
C) friend
D) void

E) A) and B)
F) B) and D)

Correct Answer

verifed

verified

In C++, >> is used as a stream extraction operator and as a right shift operator.

A) True
B) False

Correct Answer

verifed

verified

A class template is called a(n) ____________________ type because it specifies how a generic class template is to be customized to form a specific template class.

Correct Answer

verifed

verified

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;

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

Operator functions typically return void.

A) True
B) False

Correct Answer

verifed

verified

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) ;

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

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


A) increment
B) assignment
C) decrement
D) relational

E) All of the above
F) None of the above

Correct Answer

verifed

verified

The ____________________ members of a class are local to the class and, therefore, cannot be accessed outside of the class.

Correct Answer

verifed

verified

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&) ;

E) A) and C)
F) A) and D)

Correct Answer

verifed

verified

The general syntax to overload the stream extraction operator >> for a class is ____.


A) istream& operator>>(istream&, className&) ;
B) const istream& operator>>(istream&, className&) ;
C) friend operator>>(istream&, className&) ;
D) friend istream& operator>>(istream&, className&) ;

E) A) and B)
F) B) and C)

Correct Answer

verifed

verified

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

E) None of the above
F) All of the above

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

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


A) bool operator!=(rectangle&) const;
B) bool operator!=(const rectangleType&) const;
C) int operator!=(const rectangleType) const;
D) int operator!=(rectangle&) const;

E) A) and B)
F) A) and D)

Correct Answer

verifed

verified

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


A) int
B) bool
C) char
D) void

E) B) and C)
F) C) and D)

Correct Answer

verifed

verified

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

E) All of the above
F) A) and D)

Correct Answer

verifed

verified

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
B) False

Correct Answer

verifed

verified

The ____________________ operator function as a member of a class has only one parameter; as a nonmember of a class, it has two parameters.

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

Showing 21 - 40 of 50

Related Exams

Show Answer