Exam 17: Templates

arrow
  • Select Tags
search iconSearch Question
  • Select Tags

Given a class template,how many different times can you instantiate the class?

(Multiple Choice)
4.8/5
(35)

In a template,all members must be private

(True/False)
4.9/5
(32)

A class template may not use dynamic memory allocation.

(True/False)
4.7/5
(36)

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)

Which of the following are valid template prefixes?

(Multiple Choice)
4.8/5
(43)

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
close modal

Filters

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