Quiz 11

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

Given that v1 and v2 are vectors, what is returned by the function call std::equal( v1.begin(), v1.end(), v2.begin() )

A bool indicating whether v1 and v2 are equal.

Exception handling should not be used:

As an alternative for program control.

The order of the arguments passed to function replace_copy_if must be:

InputIterator, InputIterator, OutputIterator, PredicateFunction, ReplacementValue.

If v1 is a vector< int > containing some number of int elements sorted in ascending order, after these statements execute: std::vector< int > results1; std::vector< int > results2; std::unique_copy( v1.begin(), v1.end(), std::back_inserter( results1 ) ); std::reverse_copy( v1.begin(), v1.end(), std::back_inserter( results2 ) ); which of the following could be true?

The first element in results1 matches the last element in results2.

Which statement about class unique_ptr (of the new C++ standard) and dynamic memory allocation is false?

When a unique_ptr object destructor is called (for example, when a unique_ptr object goes out of scope), it performs a destroy operation on its pointer data member.

Lambdas begin with the lambda introducer ________, followed by a parameter and function body.

[]

Lambdas return types:

can be inferred automatically if the body is a single statement of the form return expression; otherwise, the return type is void by default.

The easiest way to set all the values of a vector to zero is to use function:

fill

Function objects have their functions called by using:

operator()

The ________ function would produce a sequence containing three elements when passed the sequences 1, 2 and 1, 2, 3, 4, 5 as first/second and third/fourth arguments, respectively.

set_symmetric_difference

Which of the following function calls would not return the value that is its first argument?

std::max( 'd', 'k' )

Select the false statement regarding exceptions.

The C++ standard has a hierarchy of exception classes. Correct Response All exception classes are accessible via <exception>. Several classes derive from class exception. The what function can be overridden in each class derived from exception.

If dynamic memory has been allocated for an object and an exception occurs, then:

A memory leak could result.

Function mismatch returns:

A pair containing two iterators pointing to the two locations in the specified sequences that do not match.

Attributes of a heap do not include:

A preference to pop, rather than push, elements in the heap.

Functions lower_bound, upper_bound and equal_range are different in their:

Return types.

The for_each function applies a general function to each element in the specified range. This general function should:

Take an argument of the elements' type and return nothing.

Exception handling may allow a program to:

Terminate in a controlled manner. Be more robust and fault-tolerant. Continue executing as if no problem was encountered. Correct Response All of these.

An exception:

Terminates the block where the exception occurred.

To rethrow an exception, the exception handler must:

Use the throw; statement.


Conjuntos de estudio relacionados

6.6.6 Practice Questions Active Directory Sites

View Set