-2
friend ostream& operator<< (ostream& os,const aList<T>&);

template <class T>
ostream & operator << (ostream &output,const aList<T>& a){
    output<<a.length;
    return output; 
}

.....................................

error: g++    -c -g -MMD -MP -MF "build/Debug/Cygwin-Windows/aList.o.d" -o build/Debug/Cygwin-Windows/aList.o aList.cpp
In file included from aList.cpp:2:0:
aList.h:22:68: warning: friend declaration ‘std::ostream& operator<<(std::ostream&, const aList<T>&)’ declares a non-template function [-Wnon-template-friend]
             friend ostream& operator<< (ostream& os,const aList<T>&);
                                                                    ^
aList.h:22:68: note: (if this is not what you intended, make sure the function template has already been declared and add <> after the function name here) 
mkdir -p dist/Debug/Cygwin-Windows
g++     -o dist/Debug/Cygwin-Windows/alist build/Debug/Cygwin-Windows/_ext/2ebfcef6/newstring.o build/Debug/Cygwin-Windows/aList.o build/Debug/Cygwin-Windows/alist1.o 
build/Debug/Cygwin-Windows/alist1.o: In function `main':
/cygdrive/c/Users/Zunera Jamal/Documents/NetBeansProjects/aList/alist1.cpp:50: undefined reference to `operator<<(std::ostream&, aList<newstring> const&)'
/cygdrive/c/Users/Zunera Jamal/Documents/NetBeansProjects/aList/alist1.cpp:50:(.text+0x2ca): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `operator<<(std::ostream&, aList<newstring> const&)'
463035818_is_not_an_ai
  • 109,796
  • 11
  • 89
  • 185
Xuni
  • 1
  • 5
    Please create a [Minimal, Complete, and Verifiable Example](http://stackoverflow.com/help/mcve) to show us. When and where is the `friend` declaration? – Some programmer dude Oct 09 '17 at 17:05

1 Answers1

0

On first glance, the fact that your friend declaration is referring to but is outside of the template declaration seems like your first issue.

Check out this question. It seems very much related: friend declaration declares a non-template function

Stuart Thompson
  • 1,839
  • 2
  • 15
  • 17