Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please only answer these questions if you are sure your answer is right. Negativ

ID: 3696965 • Letter: P

Question

Please only answer these questions if you are sure your answer is right. Negative reviews will be given for wrong answers.

1C.

Select one:

a. int x=3, y=4;
cout << larger(x,y);

b. float x=3, y=4;
cout << larger(x,y);

c. char x='3', y='4';
cout << larger(x,y);

d. char x[]="3", y[]="4";
cout << larger(x,y);

2C.

Select one:

a. Add the template prefix.

b. Change all occurrences of int to T.

c. Change the parameter type of addItem to T.

d. Change the return type of getItem to T.

e. Change the return type of getSize to T.

f. Change the parameter type of the implicit constructor to T.

g. Add the template prefix and Change all occurrences of int to T

h. Add the template prefix, Change the parameter type of addItem to T and Change the return type of getItem to T

i. Add the template prefix, Change the parameter type of addItem to T, Change the return type of getItem to T, and Change the parameter type of the implicit constructor to T

3C.

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

Select one:

a. 0

b. 1

c. 1 for each different data type

d. as many as you need, but only one data type

e. as many as you need, of any data types

4C.

Classes can be defined as templates.

Select one:

True

False

5C.

Writing a template class

Select one:

a. allows us to skip the implementation of that template class.

b. allows us to write one class definition that can hold different data types.

c. means we never have to write non-template classes again.

d. is illegal.

Explanation / Answer

1c. (d) - char x[]="3", y[]="4";
cout << larger(x,y);

isnot a valid calls to larger.

2c. (g) - Add the template prefix and Change all occurrences of int to T.

3c (e) -as many as you need, of any data types.

4c (a) Clases can be defined as templates is true.

5c (b) - allows us to write one class definition that can hold different data types.