Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.

Multiply
Multiply is a math code snippet to multiply each element in a std::vector by a certain value.
Multiply can be defined in multiple ways:

Multiply using an algorithm and the C++0x STL
Using an algorithm and the STL
Using an algorithm and Boost
Using a for loop
Prefer algorithms over loops [1][2].

Multiply using an algorithm and the C++0x STL
#include <algorithm> |

Multiply using an algorithm and the STL
This is the answer of Exercise #9: No for-loops.
#include <algorithm> |

Multiply using an algorithm and Boost
This is the answer of Exercise #9: No for-loops.
#include <algorithm> |
Multiply using a for loop
#include <vector> |
Prefer algorithms over loops [1][2].
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.