I have a helper function that creates an Array_Ref obj. The function has a parameter, vector<t> – that the compiler is complaining about. I’m using VS2010.
- I put the function in a
.hby itself. - I put the function in
Array_Ref.h - I put it in a
.cppfile. - I put
typenameinfront of vector<T> - I put
typedef typenamein front ofvector<T>
Nothing seems to work.
#include <vector>
template<class T>
Array_Ref<T> make_ref(vector<T> &v, int s)
{
return (v.size()) ? Array_Ref<T>(v,s): Array_Ref<T>(0,0);
}
I’m getting:
error C2143: syntax error : missing ';' before '<'
error C4430: missing type specifier - int assumed.
error C2988: unrecognizable template declaration/definition
error C2059: syntax error : '<'
However, putting this in the same header file as Array_Ref.h works just fine:
template<class T,int size>
Array_Ref<T> make_ref(T (&p)[size])
{
return (p) ? Array_Ref<T>(p,size): Array_Ref<T>(0,0);
}
It’s
std::vector, notvector. Also, you don’t appear to have definedArray_Refanywhere.