Exam 17: Templates

arrow
  • Select Tags
search iconSearch Question
  • Select Tags

Using template functions is an example of ___________ abstraction.

Free
(Short Answer)
4.7/5
(36)
Correct Answer:
Verified

Algorithm

When you define a class as a template,then that class can contain _________ data type.

Free
(Short Answer)
4.9/5
(35)
Correct Answer:
Verified

any well-defined

Which of the following describes a class that would be a good candidate for conversion to a template class?

Free
(Multiple Choice)
4.8/5
(35)
Correct Answer:
Verified

A

When would you want to make a function a function template?

(Multiple Choice)
4.8/5
(34)

Classes can be defined as templates.

(True/False)
4.9/5
(34)

Templates are an example of algorithm abstraction

(True/False)
4.8/5
(36)

Writing a template class

(Multiple Choice)
4.9/5
(30)

If your program defines a class template,then the compiler will generate a class for each different data type for which it is instantiated.

(True/False)
4.9/5
(41)

Which of the following is a correct template prefix?

(Multiple Choice)
4.7/5
(44)

All classes should be converted to templates

(True/False)
4.9/5
(37)

In a template function definition,all parameters must be of the template class T).

(True/False)
4.9/5
(34)

Given the following template function definition,which of the following is not a valid invocation of the function? Template <class T> Void swapT& left,T& right) { //implementation goes here,not relevant to the question } Int int1,int2; Float flt1,flt2; Char ch1,ch2; String s1,s2;

(Multiple Choice)
4.8/5
(43)

Which would be the correct way to instantiate a containerClass object in your main program? Template <class T> Class containerClass { Public: ContainerClass); ContainerClassint newMaxSize); ContainerClassconst containerClass& source); ~containerClass); T getItem); Int getCount); Int getSize); Void addItemT item); Private: T *container; Int maxSize,count; };

(Multiple Choice)
4.9/5
(38)

If you want to make a function a template function,you must precede the function declaration and definition with

(Multiple Choice)
4.7/5
(29)

Given the following function template,which of the following are NOT valid calls to larger? Template <class T> T largerconst T& left,const T& right) { Ifleft > right) Return left; Else Return right; }

(Multiple Choice)
4.9/5
(36)

Using templates in your program where warranted,is an example of

(Multiple Choice)
4.9/5
(35)

In a class template implementation,every use of the class name as the name of the class should be followed by <T>.

(True/False)
4.9/5
(34)

If you need to pass a class template named myClass)function an object of the class as a value parameter,then the type of the parameter is

(Short Answer)
4.7/5
(30)

In the following function template,what must be true in order to use the function with a given data type? Template <class T> Int smallest T array[],int size) { Int small=0,i; Fori=0;i<size;i++) { Ifarray[i] < array[small]) Small=i; } Return small; }

(Multiple Choice)
4.7/5
(42)

If you define some list class template in your program,and then declare a list of integers,2 lists of doubles and 1 list of strings,how many different version of the template class will the compiler provide?

(Multiple Choice)
4.7/5
(38)
Showing 1 - 20 of 33
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)