How do I make the following function inside a class and then access this function from main? My class is just a collection of a bunch of static functions.
template<typename T> double foo(vector<T> arr);
How do I make the following function inside a class and then access this function from main? My class is just a collection of a bunch of static functions.
template<typename T> double foo(vector<T> arr);
Define the function in the .h file.
Works fine for me
a.h
main.cpp
You make a template class:
Also note that you should pass
vector
by reference, or in your case, alsoconst
reference would do the same.You can then call the function like: