I mean the following. I want a template function that takes two vector iterators (or two pointers to an array from double) and returns double, which is somehow related to the vector iterators or pointers of the array that I pass. However, I want this to work for double or int or any arithmetic type.
I think I’m not allowed to say:
template <class T>
T* func(T Begin, T End)
T new_variable = Begin + 5;
return (*new_variable);
}
because the compiler will not understand what T * means. The solution I was thinking about is to take what I am trying to return and make it the third argument:
template <class T>
void func(T Begin, T End, T* new_variable)
new_variable = Begin + 5;
return (*new_variable);
}
Will this work? Even so, is there any other way to do what I'm trying to do? (Sorry if I was not clear enough.)