5. (C++ 11 Combinations) Based on the discussion in Section 11.4.3 consider the following general scenarios:

Question:

5. (C++ 11 Combinations)

Based on the discussion in Section 11.4.3 consider the following general scenarios:

 Using function wrappers with embedded tuples.

 Using function wrappers with embedded functions (these are called functionals).

 Using tuples containing function wrappers.

 Using tuples containing other tuples (nested tuples).

Answer the following questions:

a) Create simple examples of each of the above scenarios to gain some understanding of the syntax.

b) How does this functionality support the ability to create and maintain loosely coupled systems?

c) Consider the problem of modelling real-valued functions of a single variable and their integrals as given by the formula:

I(f ) = ∫

b a

f (x)dx. (11.1)

In fact, we are defining a higher-order function (or functional in this case) that models the integral of the function f on the interval

(a, b). Determine how to model equation (11.1) using C++ syntax.

d) We generalise equation (11.1) to the case of a bilinear mapping:

I(f , g) = ∫

b a

f (x)g(x)dx. (11.2)

Determine how to model equation (11.2) using C++ syntax (hint: use lambda functions).

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: