I'm pretty sure the standard says something about modifying the value past to the function in for_each(). If you want to change a value past to a function then I would investigate the transform() function.
Oops. My bad, I was thinking about something else. Please ignore.
Is there any particular reason you're using for_each when you already have C++11's range based for loops available? Is it part of an assignment that your add() function has to exist? The following would be easier.
for(auto& i : vec)
i += 2;
for(auto i : vec)
cout << i;
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"
I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:
Runtime run = Runtime.getRuntime();
Process pr = ...