What I mean is the following. I want a template function that takes two vector iterators (or two pointers to array of double) and returns a double that is somehow related to the vector iterators or array pointers 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 won't understand what T* means. A solution I thought of is to take what I'm trying to return and make it a 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 if so, is there another way of doing what I'm trying to do? (Sorry if I haven't been clear enough.)