Wednesday 8 June 2022

Chapter 24 // Exercise 2 - Principles & Practice Using C++

In this exercise I am using Visual Studio 2019 and a modified version of the std_lib_facilities header found here.

Chapter 24 // Exercise 2

Do exercise 1 again, but with function objects, rather than functions. Hint: Matrix.h contains examples.


So in the header there's already a function object called Mul_assign that you can call with apply like this:
m.apply(Mul_assign<int>(), 3) and that will triple all the elements.

No comments:

Post a Comment