Hello! I'm trying to redefine the >> and << operators. Everything is working well when I try to do it with ordinary data structures. The problem comes when I try to use a template.
That's a linking error, your code actually compiled. I can only guess that you placed the definition of those operators in some source file instead of the header.
Because you're using templates.
As templates must be compiled in a different way, they must go in the header file.
If you want them in the source file, it's also ok if you declare/define them inside the class.
@LB: Why shouldn't it be Stack<T> ? Is that a typo? (@lines 9 and 14)
I tried both Stack and Stack<T>. Both ways work. :)
And so you are telling me that if the whole code except the main() function was in a header file it would work to define them outside the class? I will try :)