Thanks in advance for looking at my question. So I'm trying to learn C++ and I'm working on templates. I created a simple linked list class and tested it to ensure it worked. Then I tried add templates as an exercise in learning how they work. Obviously since I'm here I'm having trouble. Any help getting my example code to work would be appreciated.
Additionally, I have a few generic template questions.
1) What do I need to do when I have multiple classes involved with templates? I believe that is my problem here.
2) Is it simpler to declare the internal class named Node externally? Or maybe just make it a struct?
3) I've seen many comments about how you should just define all your template code in a header file. Isn't this what the keyword export is for? Why would I not want to do this?
4) Since the overloaded << operator only supports numeric types of data due to my implementation I was going to implement a class specialization for strings as follow up exercise. In my experience in java it would just be easier to create an interface and only work with objects that implement it. In your C++ experience is it more likely to see a completely virtual/abstract base class (AKA pseudo interface) or to implement class specialization for templates?
> Any help getting my example code to work would be appreciated.
first you need to tell us what the problem is. If you've got compile errors then you should post them.
> Is it simpler to declare the internal class named Node externally?
¿do you want the client code to create nodes?
> Or maybe just make it a struct?
that's what it is.
> Since the overloaded << operator only supports numeric types of data due to my implementation
¿why can't you make your implementation generic?