Question: please write in c++ Laboratory Work No. 5 C++Templates Task 1: write a functor class with a private variable ' i ', it should start
Laboratory Work No. 5 C++Templates Task 1: write a functor class with a private variable ' i ', it should start at 0 when an object is created, and it should increase by 1 every time the functors 'operator O ' function is called, like iota. Your 'operator 0 ' should receive an 'std::functionO> ' object, pass in the ' i ' value to the std::function and return the output of the std:function. Write a suitable main function to test your functor. Task 2: Write a template class called MaxElement that takes in any data type, it should have a private variable ' max ', and a constructor that initializes max to a value. Add a function called compare, compare should receive a template variable ' y ' of the same type and compare with the max variable, if y is greater than max then it should become the new max, else the max should stay the same. Return the new max in both cases
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
