The naive way would be to linearly iterate the range and multiply with each number in the range.
Example: Array: {1,2,3,4,5,6,7,8,9,10}; Multiply index 3 to index 8 wit
As far as I know the only way is to iterate through the vector, and apply the multiplication.
You could define a function like so:
void VecMultiply(std::vector& pVector, int Multiplier);
and implement it like:
void VecMultiply(std::vector& pVector, int Multiplier)
{
for (unsigned int i = 0; i < pVector.size(); i++)
{
*pVector[i] *= Multiplier;
}
}
Or you could even pass a vector of anything multiplied by anything using templates:
template
template
void VecMultiply(std::vector& pVector, M Multiplier)
{
for (unsigned int i = 0; i < pVector.size(); i++)
{
*pVector[i] *= Multiplier;
}
}