Deck 11: Using Templates
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
Match between columns
سؤال
Match between columns
سؤال
Match between columns
سؤال
سؤال
Match between columns
سؤال
سؤال
سؤال
Match between columns
سؤال
Match between columns
سؤال
Match between columns
سؤال
Match between columns
سؤال
سؤال
سؤال
Match between columns
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/54
العب
ملء الشاشة (f)
Deck 11: Using Templates
1
The keyword ____ can replace class in a template definition in some C++ compilers.
A) struct
B) generic
C) template
D) typename
A) struct
B) generic
C) template
D) typename
D
2
To create a function template that employs multiple generic types, you simply use a(n) ____ for each type.
A) #include statement
B) function prototype
C) unique type identifier
D) separate template class
A) #include statement
B) function prototype
C) unique type identifier
D) separate template class
C
3
Function templates serve as an outline or pattern for a group of functions that differ in the types of parameters they use.
True
4
You ____ functions when you create functions with the same name but with different argument lists.
A) abstract
B) replace
C) overload
D) override
A) abstract
B) replace
C) overload
D) override
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
5
To create a class template, you begin with the template ____.
A) implementation
B) prototype
C) declaration
D) definition
A) implementation
B) prototype
C) declaration
D) definition
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
6
You can use multiple explicit types when you call a template function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
7
A ____ is a data structure in which elements are removed in the same order they were entered.
A) queue
B) list
C) stack
D) vector
A) queue
B) list
C) stack
D) vector
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
8
Complete the following function template:
____
T reverse(T x)
{
Return -x;
}
A) template : class T
B) template
C) template (class T)
D) template {class T}
____
T reverse(T x)
{
Return -x;
}
A) template : class T
B) template
C) template (class T)
D) template {class T}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
9
The purpose of container classes is to manage groups of other classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
10
In template , T stands for a programmer created class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
11
Function templates ____ support multiple parameters.
A) can
B) cannot
C) sometimes
D) should not
A) can
B) cannot
C) sometimes
D) should not
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
12
Function templates cannot use variables of multiple types.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
13
The option of using multiple types in a function template is available on all C++ compilers.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
14
You can overload function templates only when each version of the function takes a different parameter list.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
15
A(n) ____ is one that can stand for any number of C++ types.
A) abstract data type
B) generic parameter
C) structure
D) container class
A) abstract data type
B) generic parameter
C) structure
D) container class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
16
If doubleVal() is a function template that takes one parameterized type, doubleVal (a) is exactly the same as ____.
A) doubleVal( a)
B) doubleVal (a)
C) doubleVal(a)
D) doubleVal (a)
A) doubleVal( a)
B) doubleVal (a)
C) doubleVal(a)
D) doubleVal (a)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
17
The ____ operator is automatically defined for classes you create, but you can also overload it.
A) %
B) =
C) +
D) >>
A) %
B) =
C) +
D) >>
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
18
The function call ____ specifies that someFunction 's parameterized type (for example, T ) will be char , no matter what type someArgument is.
A) someFunction:char(someArgument);
B) someFunction (someArgument);
C) someFunction((char) someArgument);
D) someFunction{char}(someArgument);
A) someFunction:char(someArgument);
B) someFunction (someArgument);
C) someFunction((char) someArgument);
D) someFunction{char}(someArgument);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
19
The terms template function and ____ are often used interchangeably.
A) template class
B) generic method
C) function template
D) class template
A) template class
B) generic method
C) function template
D) class template
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
20
Consider the following function template:
Template
Void repeatValue(T val, int times)
{
Int x;
For(x = 0; x
Which of the following statements is true?
A) No restrictions apply.
B) Any type of object from a user defined class can be displayed the specified number of times.
C) It can be called only with primitive data types.
D) Any type of object can be displayed the specified number of times as long as the << operator is defined for the object's data type.
Template
Void repeatValue(T val, int times)
{
Int x;
For(x = 0; x
Which of the following statements is true?
A) No restrictions apply.
B) Any type of object from a user defined class can be displayed the specified number of times.
C) It can be called only with primitive data types.
D) Any type of object can be displayed the specified number of times as long as the << operator is defined for the object's data type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
21
What happens when you call a function template?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
22
The designation of the parameterized type is ____________________; that is, it is determined not by naming the type, but by the compiler's ability to determine the argument type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
23
You can calculate the size of an array (the number of elements) called nums as follows ____.
A) sizeof(nums)
B) nums.length
C) nums.length()
D) sizeof(nums)/sizeof(nums[0]);
A) sizeof(nums)
B) nums.length
C) nums.length()
D) sizeof(nums)/sizeof(nums[0]);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
24
In Java, C#, and Smalltalk, all objects derive from the same container class, called ____.
A) Object
B) Container
C) Base
D) Class
A) Object
B) Container
C) Base
D) Class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
25
FIFO stands for ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
26
A(n) ____ is a template class that has been written to perform common class tasks.
A) parameterized argument
B) abstract data type
C) container class
D) generic class
A) parameterized argument
B) abstract data type
C) container class
D) generic class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
27
Where in your program can you place function templates? Do any restrictions apply?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
28
Because a generic linked list class is so useful, the developers of C++ have already created such a container class: its name is ____, and it contains functions such as merge() and reverse() .
A) set
B) list
C) linkedList
D) vector
A) set
B) list
C) linkedList
D) vector
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
29
Write a function template that compares three parameters and returns the largest of the three.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
30
The subscript for any array can hold a value of 0 through ____.
A) 1
B) the array size
C) 1 less than the array's size
D) 1 more than the array's size
A) 1
B) the array size
C) 1 less than the array's size
D) 1 more than the array's size
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
31
Different versions of ____________________ function templates do not need to use the same identifier to stand in for the variable type or class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
32
LIFO stands for ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
33
Provide an example of an overloaded function template.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
34
Explain why overloading can sometimes require a lot of unnecessary, tedious coding.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
35
When you create a(n) ____, you create a list of same-type objects at adjacent memory locations.
A) array
B) linked list
C) queue
D) stack
A) array
B) linked list
C) queue
D) stack
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
36
Which of the following is not a common task to perform with an array?
A) Display an element in a specified position in the array.
B) Reverse the order of elements in an array.
C) Convert the array to a stack.
D) Sort the elements in an array in ascending or descending order.
A) Display an element in a specified position in the array.
B) Reverse the order of elements in an array.
C) Convert the array to a stack.
D) Sort the elements in an array in ascending or descending order.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
37
The terms template class and ____________________ are often used interchangeably.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
38
When using function templates, you can code empty angle brackets after the function name in a function call to indicate that the types should be deduced and not ____________________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
39
A ____ is a data structure in which elements are removed in the reverse order from which they were entered.
A) queue
B) list
C) stack
D) vector
A) queue
B) list
C) stack
D) vector
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
40
What are macros? Should you use them?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
41
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
42
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
43
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
44
When is explicitly specifying a type for the parameterized type useful?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
45
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
46
At a minimum, what components should a linked list element have?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
47
Write the class definition for a Number class that has one data member which can hold any number, a constructor that takes an argument, and a displayNumber() function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
48
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
49
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
50
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
51
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
52
Create a displayAndCompare() function that displays two values, compares them, and displays a message indicating which is larger. The function works when any two parameters are passed, whether or not the two parameters are of the same type, as long as > and == are defined correctly for the parameters.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
53
What are common uses of template classes?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck
54
Match between columns
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 54 في هذه المجموعة.
فتح الحزمة
k this deck