Oct 23, 2008 at 6:44pm UTC
How do you overload the == operator in a stack?
Oct 23, 2008 at 6:55pm UTC
I would imagine, the same way you override all other operators. But making sure it's a global operator the same as the original ==. The question is, why would you want to override it?
Oct 23, 2008 at 7:15pm UTC
i need to be able to see if stack1 == stack2
Last edited on Oct 23, 2008 at 7:20pm UTC
Oct 23, 2008 at 7:23pm UTC
There is already an operator for this.
Oct 23, 2008 at 7:35pm UTC
yes but the assignment asks for me to overload the == operator so that i can compare 2 stacks
Oct 23, 2008 at 7:40pm UTC
lol i know how to overload the == operator in a general program, but you need templates in a stack and you cant overload the == the same way
i need to be able to compare stack1 (which contains 1,2,3) to stack2 (which contains 2,3,4,5) and so on
Oct 23, 2008 at 7:52pm UTC
yeah i have the syntax figured out, im just having trouble writing the definition.
i cant seem to figure out how to compare the size of the stack and the elements of the stack
Oct 23, 2008 at 8:09pm UTC
neither of those showed me how to define the the function
Oct 23, 2008 at 8:29pm UTC
That's what your suppose to come up with yourself. We aren't here to give you answers to your homework.
Oct 23, 2008 at 9:05pm UTC
my professor instructed us to go online and look for how to do it
Oct 23, 2008 at 9:13pm UTC
Then start digging through the source code to your compiler's STL. Have a look at how it's done there.