Deck 24: C++11 Additional Features
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/56
Play
Full screen (f)
Deck 24: C++11 Additional Features
1
Each time a new shared_ptr to the resource is created, the reference count ________, and each time one is destroyed, the reference count ________.
A) increases, increases
B) increases, decreases
C) decreases, increases
D) decreases, decreases
A) increases, increases
B) increases, decreases
C) decreases, increases
D) decreases, decreases
B
2
A copy constructor, a destructor and an overloaded assignment operator are usually provided as a group for any class that uses dynamically allocated memory. With the addition of move semantics in C++11, you should also provide __________.
A) a move constructor
A) and b)
B) a move assignment operator
C) an overloaded move destructor
D) both
A) a move constructor
A) and b)
B) a move assignment operator
C) an overloaded move destructor
D) both
D
3
A unique_ptr automatically calls ________ to free its associated dynamic memory when the unique_ptr is destroyed or goes out of scope.
A) release
B) destroy
C) erase
D) delete
A) release
B) destroy
C) erase
D) delete
D
4
The ________ multithreading header contains class thread for manually creating and starting threads, and functions yield, get_id, sleep_for and sleep_until.
A)
B)
C)
D)
A)
B)
C)
D)
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
5
Weak_ptrs should be used in any situation where you need to ________ the resource but don't want to assume any management responsibilities for it.
A) delete
B) copy
C) observe
D) move
A) delete
B) copy
C) observe
D) move
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
6
Which statement is false:
A) A weak_ptr points to the resource managed by a shared_ptr without assuming any responsibility for it.
B) The reference count for a shared_ptr doesn't increase when a weak_ptr references it. That means that the resource of a shared_ptr can be deleted while there are still weak_ptrs pointing to it. When the last shared_ptr is destroyed, the resource is deleted and any remaining weak_ptrs are set to NULL.
C) One use for weak_ptr s is to avoid memory leaks caused by circular references.
D) None of the above.
A) A weak_ptr points to the resource managed by a shared_ptr without assuming any responsibility for it.
B) The reference count for a shared_ptr doesn't increase when a weak_ptr references it. That means that the resource of a shared_ptr can be deleted while there are still weak_ptrs pointing to it. When the last shared_ptr is destroyed, the resource is deleted and any remaining weak_ptrs are set to NULL.
C) One use for weak_ptr s is to avoid memory leaks caused by circular references.
D) None of the above.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
7
The internal pointer is deleted once the last ________ to the resource is destroyed.
A) smart pointer
B) shared_ptr
C) weak_ptr
D) link
A) smart pointer
B) shared_ptr
C) weak_ptr
D) link
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
8
The ________ multithreading header contains classes and class templates for ensuring mutually exlusive access to resources shared among threads in an application.
A)
B)
C)
D)
A)
B)
C)
D)
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
9
When the reference count reaches zero, the ________ is deleted and the memory is released.
A) internal pointer
B) external pointer
C) internal reference
D) external reference
A) internal pointer
B) external pointer
C) internal reference
D) external reference
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
10
In the following function int square(int value)
{
Return value * value;
}
The noexcept keyword indicates that this function ________.
A) does not catch exceptions
B) does not throw exceptions
C) does not test for exceptions
D) None of the above.
{
Return value * value;
}
The noexcept keyword indicates that this function ________.
A) does not catch exceptions
B) does not throw exceptions
C) does not test for exceptions
D) None of the above.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the following statements is false?
A) The thread launch policy is a value from the launch enum-either launch::async, launch::deferred or both separated by a bitwise OR (|) operator.
B) The thread launch policy value launch::async indicates that a specified function should execute in the current thread.
C) Function async returns an object of class template future that you can use when the thread completes execution to obtain data returned by the function that async executes. The thread launch policy value launch::deferred indicates that a specified function should execute in the same thread when the program uses the future object returned by function template async to get the result.
D) To ensure that a program does not terminate until its threads terminate and to receive the results from each thread, we call each future's get member function. This causes the program to wait until the corresponding threads complete execution-known as joining the threads-before executing the remaining code in main.
A) The thread launch policy is a value from the launch enum-either launch::async, launch::deferred or both separated by a bitwise OR (|) operator.
B) The thread launch policy value launch::async indicates that a specified function should execute in the current thread.
C) Function async returns an object of class template future that you can use when the thread completes execution to obtain data returned by the function that async executes. The thread launch policy value launch::deferred indicates that a specified function should execute in the same thread when the program uses the future object returned by function template async to get the result.
D) To ensure that a program does not terminate until its threads terminate and to receive the results from each thread, we call each future's get member function. This causes the program to wait until the corresponding threads complete execution-known as joining the threads-before executing the remaining code in main.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
12
There are many cases in which the object being copied is about to be destroyed, such as a temporary object that was returned from a function by value or a local object that's going out of scope. In such cases, it's better to move the contents of the object that's about to be destroyed into the destination object, thus avoiding ________.
A) a memory leak
B) a runtime error
C) a memory exhaustion error
D) any copying overhead
A) a memory leak
B) a runtime error
C) a memory exhaustion error
D) any copying overhead
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
13
The ________ multithreading header contains class templates, a function template and enums that enable you specify functions to execute in separate threads and to receive the results of those functions when the threads complete.
A)
B)
C)
D)
A)
B)
C)
D)
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
14
Which statements is false:
A) shared_ptrs provide the pointer operators dot(.), star(*) and arrow(->).
B) We get the reference count using the shared_ptr member function use_count, which returns the number of shared_ptrs to the resource.
C) Changes made to the resource of a shared_ptr are "seen" by all shared_ptrs to that resource.
D) shared_ptr member function reset releases the current resource and sets the shared_ptr to NULL. If there are no other shared_ptrs to the resource, it's destroyed.
A) shared_ptrs provide the pointer operators dot(.), star(*) and arrow(->).
B) We get the reference count using the shared_ptr member function use_count, which returns the number of shared_ptrs to the resource.
C) Changes made to the resource of a shared_ptr are "seen" by all shared_ptrs to that resource.
D) shared_ptr member function reset releases the current resource and sets the shared_ptr to NULL. If there are no other shared_ptrs to the resource, it's destroyed.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
15
The ________ multithreading header contains classes, a function and an enum that are used together with facilities in header to implement thread synchronization. In particular, condition variables can be used to make threads wait for a specific condition in a program, then to notify the waiting threads when that condition is satisfied.
A)
B)
C)
D)
A)
B)
C)
D)
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
16
Which statement is false?
A) There's overhead inherent in multithreading.
B) Simply dividing a task into two threads and running it on a dual core system does not run it twice as fast, though it will typically run faster than performing the thread's tasks in sequence on one core.
C) Executing a multithreaded application on a single-core processor can actually take longer than simply performing the thread's tasks in sequence.
D) None of the above.
A) There's overhead inherent in multithreading.
B) Simply dividing a task into two threads and running it on a dual core system does not run it twice as fast, though it will typically run faster than performing the thread's tasks in sequence on one core.
C) Executing a multithreaded application on a single-core processor can actually take longer than simply performing the thread's tasks in sequence.
D) None of the above.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
17
Smart pointers ________.
A) strengthen the process of memory allocation and deallocation
B) help you write exception safe code
C) help prevent memory leaks
D) all of the above
A) strengthen the process of memory allocation and deallocation
B) help you write exception safe code
C) help prevent memory leaks
D) all of the above
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
18
If a program throws an exception before delete has been called on a pointer, it creates a memory leak. After an exception is thrown, a(n) ________ destructor will still be called, which calls delete on the pointer for you.
A) reference's
B) inherited
C) smart pointer's
D) virtual
A) reference's
B) inherited
C) smart pointer's
D) virtual
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
19
Shared_ptrs use ________ counting to determine how many shared_ptrs point to the resource.
A) pointer
B) link
C) smart pointer
D) reference
A) pointer
B) link
C) smart pointer
D) reference
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
20
Though multithreading has been around for decades, interest in it is rising quickly due to the proliferation of ________ systems.
a. virtual
b. object-oriented
c. polymorphic
d. multicore
a. virtual
b. object-oriented
c. polymorphic
d. multicore
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
21
A tuple's ________ copies a tuple's elements into a new tuple of the same type.
A) copy constructor
B) move assignment
C) move constructor
D) default constructor
A) copy constructor
B) move assignment
C) move constructor
D) default constructor
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
22
The ________ operator is particularly useful when working with complex template types for which it's often difficult to provide, or even determine, the proper type declaration. Rather than trying to write a complex type declaration, for example, that represents the return type of a function, you can place in the parentheses of this operator an expression that returns the complex type and let the compiler "figure it out."
A) infer_type
B) decltype
C) determine_type
D) static_assert
A) infer_type
B) decltype
C) determine_type
D) static_assert
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
23
A tuple's ________ moves a tuple's elements into a new tuple of the same type.
A) copy constructor
B) move assignment
C) move constructor
D) default constructor
A) copy constructor
B) move assignment
C) move constructor
D) default constructor
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
24
Operator ________ enables the compiler to determine an expression's type at compile time.
a. static_assert
b. assert
c. decltype
d. typedef
a. static_assert
b. assert
c. decltype
d. typedef
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
25
In C++11, in a class called Employee that has explicitly defined constructors, you can specify that the default constructor should be generated with the declaration ________.
A) Employee() = decltype;
B) Employee() = explicit;
C) Employee() = default;
D) Employee() = generate:
A) Employee() = decltype;
B) Employee() = explicit;
C) Employee() = default;
D) Employee() = generate:
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
26
In general, move constructors and move assignment operators should not throw exceptions because they're simply moving resources, not allocating new ones. For this reason, both the move constructor and move assignment operator are declared ________ in their prototypes and definitions.
a. const
b. nothrow
c. noexcept
d. noerror
a. const
b. nothrow
c. noexcept
d. noerror
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
27
An rvalue reference is declared as ________ (where T is the type of the object being referenced. to distinguish it from a normal reference ________ (called an lvalue reference).
A) &&T, &T
B) T&, T&&
C) T*, T->
D) T&&, T&
A) &&T, &T
B) T&, T&&
C) T*, T->
D) T&&, T&
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
28
Tuples that contain the same number of members ________.
A) cannot be compared to one another
B) can be compared to one another using only equality operators
C) can be compared to one another using only relational operators
D) can be compared to one another using the relational and equality operators
A) cannot be compared to one another
B) can be compared to one another using only equality operators
C) can be compared to one another using only relational operators
D) can be compared to one another using the relational and equality operators
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
29
An rvalue reference is used to implement move semantics-instead of being ________, the object's state (i.e., its content) is ________, leaving the original in a state that can be properly destructed.
A) copied, moved
B) moved, copied
C) assigned, initialized
D) initialized, assigned
A) copied, moved
B) moved, copied
C) assigned, initialized
D) initialized, assigned
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
30
Prior to C++11 the following code created a temporary string object and passed it to push_back, which then copied it into the vector: vector myVector;
MyVector.push_back("message");
As of C++11, member function push_back is now overloaded with a version that takes a(n) ________. This allows the preceding call to push_back to take the storage allocated for the temporary string and reuse it directly for the new element in the vector. The temporary string will be destroyed when the function returns, so there's no need for it to keep its content.
A) const pointer
B) rvalue reference
C) rvalue pointer
D) const reference
MyVector.push_back("message");
As of C++11, member function push_back is now overloaded with a version that takes a(n) ________. This allows the preceding call to push_back to take the storage allocated for the temporary string and reuse it directly for the new element in the vector. The temporary string will be destroyed when the function returns, so there's no need for it to keep its content.
A) const pointer
B) rvalue reference
C) rvalue pointer
D) const reference
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
31
A common example of a variadic template is the C++11's new tuple class (from header ), which is a generalization of class template ________.
A) triple
B) quad
C) pair
D) singleton
A) triple
B) quad
C) pair
D) singleton
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
32
A tuple's ________ uses the assignment operator (=) to copy the elements of the tuple in the right operand into a tuple of the same type in the left operand. The element types stored in the constructor argument must be copy assignable.
A) move assignment
B) copy constructor
C) move constructor
D) copy assignment
A) move assignment
B) copy constructor
C) move constructor
D) copy assignment
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
33
The ________ allows you to test constant integral expressions at compile time rather than runtime.
a. static_assert declaration
b. assert macro
c. static declaration
d. assert declaration
a. static_assert declaration
b. assert macro
c. static declaration
d. assert declaration
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
34
A ________ template accepts any number of arguments, which can greatly simplify template programming.
A) variable
B) varargs
C) var_arguments
D) variadic
A) variable
B) varargs
C) var_arguments
D) variadic
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
35
If the initializer for a const variable is a function call, then the initialization occurs at ________.
A) compile time
B) load time
C) preprocessor time
D) run time
A) compile time
B) load time
C) preprocessor time
D) run time
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
36
Which of the following statements is true when a class contains both a copy constructor and a move constructor.
A) The compiler prefers to use the copy constructor.
B) The compiler prefers the move constructor.
C) The programmer explicitly specifies which to use in each case.
D) The compiler decides which one to use based on the context.
A) The compiler prefers to use the copy constructor.
B) The compiler prefers the move constructor.
C) The programmer explicitly specifies which to use in each case.
D) The compiler decides which one to use based on the context.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
37
Which of the following statements is true?
A) When working with many of the C++ Standard Library containers, you can use the new member functions emplace, emplace_front, emplace_back, emplace_after and emplace_hint to insert objects into containers.
B) The emplace member functions insert objects into contains without invoking any copy or move operations.
C) The emplace member functions actually contruct new objects in place in the new container elements.
D) All of the above.
A) When working with many of the C++ Standard Library containers, you can use the new member functions emplace, emplace_front, emplace_back, emplace_after and emplace_hint to insert objects into containers.
B) The emplace member functions insert objects into contains without invoking any copy or move operations.
C) The emplace member functions actually contruct new objects in place in the new container elements.
D) All of the above.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
38
A tuple is a fixed-size collection of values that can be of ________.
A) any integral type
B) any character type
C) any string type
D) any type
A) any integral type
B) any character type
C) any string type
D) any type
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
39
Which of the following statements creates a tuple containing two strings, an int and a double?
A) and (b).
A) tuple hammerInventory{"12345", "Hammer", 32, 9.95};
B) auto hammerInventory{make_tuple(string("12345"), string("Hammer"), 32, 9.95)};
C) tuple hammerInventory{"12345", "Hammer", 32, 9.95};
D) Both
A) and (b).
A) tuple
B) auto hammerInventory{make_tuple(string("12345"), string("Hammer"), 32, 9.95)};
C) tuple hammerInventory{"12345", "Hammer", 32, 9.95};
D) Both
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
40
A tuple's ________ creates a tuple in which each member is value initialized-primitive type values are set to 0 or the equivalent of 0 and objects of class types are initialized with their default constructors.
A) copy constructor
B) move assignment
C) move constructor
D) default constructor
A) copy constructor
B) move assignment
C) move constructor
D) default constructor
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
41
A tuple's ________ uses the assignment operator (=) to move the elements of the tuple in the right operand into a tuple of the same type in the left operand. The element types stored in the constructor argument must be copy assignable.
A) copy assignment
B) move assignment
C) copy constructor
D) move constructor
A) copy assignment
B) move assignment
C) copy constructor
D) move constructor
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
42
Which of the following statements about regular expressions is true.
A) The set of braces containing two numbers, {n,m}, matches between n and m occurrences (inclusively) of the pattern that it quantifies.
B) All of the regular expression quantifiers are greedy; they'll match as many occurrences of the pattern as possible until the pattern fails to make a match.
C) If a quantifier is followed by a question mark (?), the quantifier becomes lazy and will match as few occurrences as possible as long as there is a successful match.
D) All of the above.
A) The set of braces containing two numbers, {n,m}, matches between n and m occurrences (inclusively) of the pattern that it quantifies.
B) All of the regular expression quantifiers are greedy; they'll match as many occurrences of the pattern as possible until the pattern fails to make a match.
C) If a quantifier is followed by a question mark (?), the quantifier becomes lazy and will match as few occurrences as possible as long as there is a successful match.
D) All of the above.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
43
Which of the following statements about regular expressions is false.
A) Both "A*" and "A+" will match "A", but only "A*" will match an empty string.
B) "\d" matches any decimal digit.
C) The pattern "[aeiou]" matches any vowel.
D) The quantifier ? in a regular expression matches one or more occurrences of the preceding pattern.
A) Both "A*" and "A+" will match "A", but only "A*" will match an empty string.
B) "\d" matches any decimal digit.
C) The pattern "[aeiou]" matches any vowel.
D) The quantifier ? in a regular expression matches one or more occurrences of the preceding pattern.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
44
Which of the following initializes a vector with a list initializer:
A) vector integers{1, 2, 3, 4, 5, 6};
B) vector integers{1, 2, 3, 4, 5, 6};
C) vector integers(1, 2, 3, 4, 5, 6);
D) None of the above.
A) vector integers{1, 2, 3, 4, 5, 6};
B) vector
C) vector
D) None of the above.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
45
Which of the following statements about regular expressions is false?
A) The quantifier {n,} in a regular expression matches at least n occurrences of the preceding pattern.
B) The quantifier {n,m} in a regular expression matches between n and m (inclusive) occurrences of the preceding pattern.
C) The question mark (?) quantifier matches one occurrence of the pattern that it quantifies.
D) A set of braces containing one number, {n}, matches exactly n occurrences of the pattern it quantifies.
A) The quantifier {n,} in a regular expression matches at least n occurrences of the preceding pattern.
B) The quantifier {n,m} in a regular expression matches between n and m (inclusive) occurrences of the preceding pattern.
C) The question mark (?) quantifier matches one occurrence of the pattern that it quantifies.
D) A set of braces containing one number, {n}, matches exactly n occurrences of the pattern it quantifies.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
46
Assuming strings of the format: "Robert's birthday is 10-22-90"
What does the following regex match?
// create a regular expression
Regex expression("J.*\\d[0-35-9]-\\d\\d-\\d\\d");
A) Birthdays that occur in April and that belong to people whose names begin with "J".
B) Birthdays that belong to people whose names begin with "J".
C) Birthdays that do not occur in April and that belong to people whose names begin with "J".
D) None of the above.
What does the following regex match?
// create a regular expression
Regex expression("J.*\\d[0-35-9]-\\d\\d-\\d\\d");
A) Birthdays that occur in April and that belong to people whose names begin with "J".
B) Birthdays that belong to people whose names begin with "J".
C) Birthdays that do not occur in April and that belong to people whose names begin with "J".
D) None of the above.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
47
Which of the following statements is false?
A) Regular expressions are specially formatted strings that are used to find patterns in text.
B) Regular expressions can be used to validate data to ensure that it is in a particular format.
C) The regex library algorithm regex_search, returns true if any part of an arbitrary string matches the regular expression.
D) Character classes can be used with regular expressions. Character classes are C++ classes with escape sequences that represent groups of characters that might appear in a string.
A) Regular expressions are specially formatted strings that are used to find patterns in text.
B) Regular expressions can be used to validate data to ensure that it is in a particular format.
C) The regex library algorithm regex_search, returns true if any part of an arbitrary string matches the regular expression.
D) Character classes can be used with regular expressions. Character classes are C++ classes with escape sequences that represent groups of characters that might appear in a string.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
48
The raw string literal R"(multiple
Lines
Of
Text)"
Is treated as the string literal
A) "multiple\rlines\rof\rtext"
B) "multiple lines of text"
C) "multiple\nlines\nof\ntext"
D) raw string literals may not be treated as string literals
Lines
Of
Text)"
Is treated as the string literal
A) "multiple\rlines\rof\rtext"
B) "multiple lines of text"
C) "multiple\nlines\nof\ntext"
D) raw string literals may not be treated as string literals
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
49
Which of the following statements is true?
A) A class with multiple base classes can inherit constructors from any of its base classes.
B) If a class inherits constructors with the same signature from two or more base classes, then the derived class must define its own version of that constructor; otherwise, a compilation error occurs.
C) When a derived class is inheriting constructors from a base class and explicitly defines a constructor, if a default constructor is needed, the derived class must define a default constructor either by using = default to tell the compiler to generate the default constructor or by explicitly defining a constructor that can be called with no arguments.
D) All of the above.
A) A class with multiple base classes can inherit constructors from any of its base classes.
B) If a class inherits constructors with the same signature from two or more base classes, then the derived class must define its own version of that constructor; otherwise, a compilation error occurs.
C) When a derived class is inheriting constructors from a base class and explicitly defines a constructor, if a default constructor is needed, the derived class must define a default constructor either by using = default to tell the compiler to generate the default constructor or by explicitly defining a constructor that can be called with no arguments.
D) All of the above.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
50
C++11 enables you to define functions and constructors that receive list initializers as arguments. To do so, you specify a parameter that uses the ________ class template.
A) list_initializer
B) initializer
C) list
D) initializer_list
A) list_initializer
B) initializer
C) list
D) initializer_list
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
51
As of C++11, C++ now supports raw string literals that have the format R"optionalDelimiter(characters)optionalDelimiter"
Which of the following statements is false:
A) The optionalDelimiter before the left parenthesis, (, and after the right parenthesis,), must be identical, if provided.
B) The parentheses are required around the characters that compose the raw string literal.
C) The compiler automatically inserts backslashes as necessary in a raw string literal to properly escape special characters like double quotes ("), backslashes (\), etc.
D) None of the above.
Which of the following statements is false:
A) The optionalDelimiter before the left parenthesis, (, and after the right parenthesis,), must be identical, if provided.
B) The parentheses are required around the characters that compose the raw string literal.
C) The compiler automatically inserts backslashes as necessary in a raw string literal to properly escape special characters like double quotes ("), backslashes (\), etc.
D) None of the above.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
52
Which of the following statements about raw string literals is false.
A) Raw string literals are restricted to use with regular expressions.
B) Raw string literals may be used in any context that requires a string literal.
C) Raw string literals may include line breaks, in which case the compiler inserts \n escape sequences.
D) None of the above is false.
A) Raw string literals are restricted to use with regular expressions.
B) Raw string literals may be used in any context that requires a string literal.
C) Raw string literals may include line breaks, in which case the compiler inserts \n escape sequences.
D) None of the above is false.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
53
Which of the following statements about regular expresions is false.
a. regex_match returns true only if the entire string matches the regular expression.
b. a-z matches any lowercase letter, and A-Z matches any uppercase letter.
c. The expression \d{5} matches any five digits.
d. The character "|" matches only the expression to its left.
a. regex_match returns true only if the entire string matches the regular expression.
b. a-z matches any lowercase letter, and A-Z matches any uppercase letter.
c. The expression \d{5} matches any five digits.
d. The character "|" matches only the expression to its left.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
54
Which of the following statements about regular expressions is true?
A) The quantifier * in a regular expression matches one or more occurrences of the preceding pattern.
B) The quantifier + in a regular expression matches zero or more occurrences of the preceding pattern.
C) The quantifier {n} in a regular expression copies exactly n occurrences of the preceding pattern.
D) None of the above.
A) The quantifier * in a regular expression matches one or more occurrences of the preceding pattern.
B) The quantifier + in a regular expression matches zero or more occurrences of the preceding pattern.
C) The quantifier {n} in a regular expression copies exactly n occurrences of the preceding pattern.
D) None of the above.
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
55
A ________ iterates through the parts of a string that match a regular expression.
A) regex_iterator
B) string_iterator
C) regex_token_iterator
D) string_match_iterator
A) regex_iterator
B) string_iterator
C) regex_token_iterator
D) string_match_iterator
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck
56
In a regular expression, the dot character "." matches any single character. When the dot character is followed by a(n) ________, the regular expression matches any number of unspecified characters.
A) plus sign (+)
B) question mark (?)
C) dollar sign ($)
D) asterisk (*)
A) plus sign (+)
B) question mark (?)
C) dollar sign ($)
D) asterisk (*)
Unlock Deck
Unlock for access to all 56 flashcards in this deck.
Unlock Deck
k this deck