Hey everyone,
I'm working on an assignment and I'm having some trouble figuring out how to implement two operators. The program creates and implements a class to represent the Stack ADT using a singly-linked list. There is a driver program to test my implementation.
I have everything implemented (except the top() method) correctly as far as I can tell, but I am really struggling to implement operator= and operator<<. Here is the description for the two:
operator=: The assignment operator should be properly overloaded.
operator<<: The output operator should be overloaded so that an entire Stack can be sent to the standard output. As usual, this function will need to be a friend rather than a method. Declaring a template function to be a friend of a template class requires some special syntax.Declaring a template function to be a friend of a template class is one of the classic "gotcha's" in C++. We are trying to declare a function to be a friend of all classes that might be instantiated from the Stack template class, and most C++ compilers will quite properly refuse to do that without some special syntax. The friend declaration must contain an extra set of <> to indicate that it is a template function (however, do not code this in the actual function definition - only the friend declaration). You'll also usually need to forward declare both the template class and the template function
Here is my header file: Header File Pastebin
Here is the driver program: Driver Program
I tried to make my code as readable as possible and explain what I'm doing, let me know if you have questions about any of it.
And here is what the output should look like: Output
Any help is greatly appreciated, I have been trying to figure it out for at least 4 hours now and have had nothing but errors. Anyone that can help me get to understand how to do this would be a huge help. Also, any general improvement comments are welcome. Thanks.