Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
Add is a math code snippet to add a certain same value to each element in a std::vector.
There are multiple ways to perform Add:

The C++0x algorithm way on a std::vector<int>
The C++98 algorithm way on a std::vector<int>
The for-loop way on a std::vector<int>

The C++0x algorithm way on a std::vector<int>
Prefer algorithms over loops [1][2]
#include <algorithm> |

The C++98 algorithm way on a std::vector<int>
Prefer algorithms over loops [1][2]
#include <algorithm> |
This is the answer of Exercise #9: No for-loops.
The for-loop way on a std::vector<int>
Prefer algorithms over loops [1][2]
#include <vector> |
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.