My question is that I have two arguments vector<int>& ivec
and const int& numb
. is there a way to eliminate const int& numb
? I just want to do add 10 to all elements in the vector. Also I want to eliminate if
part, since it's empty. Thanks in advance. Please do it recursively. My goal it to use as few arguments as possible in a recursive function.
#include <iostream>
#include <vector>
using namespace std;
vector<int> addten(vector<int>& ivec, const int& numb) {
if (numb == 0) {
} else {
ivec[numb - 1] += 10;
addten(ivec, numb - 1);
}
return ivec;
}