I think as far as the LinkNode is a private member(sub-class) the code would not work.
@jwings
jwings asked
Could you explain why "typename" is needed? :)
You have to tell the compiler that LinkedList<T>::LinkNode a type name is
you should type typenamebecause you have a qualified name, LinkedList, that refers to a type and depends on a template parameter T
You cant implement template class-methdos in a source file, in a *.cpp file
You have three options to do this;
1-> implement the Methods directly in the body of the class itself, so by default all your methods are inline
1 2 3 4 5 6 7 8 9 10 11
template<class T>
class Dummy{
// do some declaration and defination
Dummy(){
}
~Dummy(){
}
//do some other things
};
2-> implement them at the same header file, after you declared the class,
after };, like
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
template<class T>
class Dummy{
// do some declaration
};
// now implement the class methods here at the same file
template<class T>
Dummy::Dummy(){
}
// do some other things
3-> implement them in another header file, for example
1 2 3 4 5 6
template<class T>
class Dummy{
// do some declaration
};
#include "dummy_impl.h"
and implement your class-medthods in dummy_impl.h file
Note: the dummy_impl.h must not include dummy.h file