Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please write in c++ Laboratory Work No. 5 C++Templates Task 1: write a functor class with a private variable ' i ', it should start
please write in c++ 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started