I have a template of an array class. I want to overload the << operator to print out the array, so i need to pass in the array, but I cannot figure out how to do this with a template. I have the overloaded function as a friend function (at the very bottom of the code piece), and I am using T as the type, but the compiler complains that the identifier is undefined. I can fix this by using int, float etc, but i want this function to work with all types, so how would I do that?
If you use a symbol like 'T', you need to put template <typename T> before the class/function so that the compiler knows it's for a template (line 108).
EDIT: Everything works if I do not have the overloaded function as a friend function, but if it is a friend function, i get a linker error. I struggle with reading linking errors. so if possible could someone help me out why i could be getting this issue with the friend function.
The error says: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class Array<int> const &)" (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABV?$Array@H@@@Z) referenced in function _main arrayTemplates