Exam 17: Templates
Exam 1: Introduction to Computer and C Programming55 Questions
Exam 2: C++ Basics54 Questions
Exam 3: More Flow of Control44 Questions
Exam 4: Procedural Abstraction and Functions That Return a Value51 Questions
Exam 5: Functions for All Sub Tasks53 Questions
Exam 6: Io Streams As an Introduction to Objects and Classes51 Questions
Exam 7: Arrays34 Questions
Exam 8: Strings and Vectors63 Questions
Exam 9: Pointers and Dynamic Arrays40 Questions
Exam 10: Defining Classes50 Questions
Exam 11: Friends, overloaded Operators, and Arrays in Classes49 Questions
Exam 12: Separate Compilation and Namespaces38 Questions
Exam 13: Pointers and Linked Lists51 Questions
Exam 14: Recursion43 Questions
Exam 15: Inheritance53 Questions
Exam 16: Exception Handling47 Questions
Exam 17: Templates33 Questions
Exam 18: Standard Template Library57 Questions
Select questions type
Given a class template,how many different times can you instantiate the class?
(Multiple Choice)
4.8/5
(35)
Give the following class template,what changes need to be made to the default constructor definition?
Template <class T>
Class containerClass
{
Public:
ContainerClass);
ContainerClassint newMaxSize);
ContainerClassconst containerClass& source);
~containerClass);
T getItem);
Int getCount);
Int getSize);
Void addItemT item);
Private:
T *bag;
Int maxSize,count;
};
ContainerClass::containerClass)
{
MaxSize = 10;
Bag = new int[maxSize];
Count=0;
}
(Multiple Choice)
4.9/5
(41)
Why can you not use the swap template function to swap two complete arrays?
Template <class T>
Void swapT& left,T& right)
{
T tmp=left;
Left=right;
Right=tmp;
}
(Multiple Choice)
4.9/5
(39)
The C++ code
template <class T>
is called the ______________________
(Short Answer)
4.8/5
(38)
Given a class template named listClass,declare a listClass object named myList that can hold doubles.
(Short Answer)
4.8/5
(33)
Given a search template function that will look for an occurrence of target in an array of items,what is necessary for the instantiating data type to implement?
(Multiple Choice)
4.7/5
(41)
If you define a function template,then the compiler will create a separate function definition for every data type that exists.
(True/False)
4.8/5
(42)
Given a class template named listClass,declare a listClass object named myList that can hold strings.
(Short Answer)
4.9/5
(45)
Given that you have two versions of a function that are the same except that one expects some integer parameters,and the other expects a float and an integer parameter,which parameters would you change to a T in order to make this a template function?
(Multiple Choice)
4.9/5
(40)
You may not have overloaded friend operators in a class template
(True/False)
4.9/5
(37)
Showing 21 - 33 of 33
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)