- Replace the multiple
times()
functions inlab_templates.h
with a single templated function. times()
takes two parameters of the same type.times()
should return a value equal to the two input parameters multiplied together.- You MUST use templates for this task.
- Building on your solution from lab_templates, a special case has been introduced in this task.
- If the
times()
function is supplied with a string (a) and and an int (b) as parameters the function should return the string repeated b times. - Write your solution in the
lab_special_template.h
file.
- In the
lab_template_iterators.h
file, write the templated function calledhow_long()
how_long()
should take two iterators as its input parameters, these iterators represent the beginning and end of a sequence.how_long()
should return an integer saying how many elements are in the supplied sequence.- You MUST use templates for this task.
- Complete the template definition of the
add_together()
function.- Should take two iterators as its input parameters.
- Should return the sum of the values in the given sequence.
- You will need to use
iterator_traits
.
- Investigate templating C++ classes.
-
Can be used to create classes that can contain different types of variables.
-
Use the supplied
stack.h
file combined with your own stack code from the data structures week to implement a templatedStack
class.{Check It!|assessment}(test-3802955942)
-