The error says:
testing.cpp:9: error: no match for 'operator==' in '(&S)->std::stack<_Tp, _Sequence>::top [with _Tp = point, _Sequence = std::deque<point, std::allocator<point> >]() == p'
I totally don't get it. Why does the stack.top() method work for one integer but not for a collection of two?
Sponsor Sponsor
Mazer
Posted: Sat Sep 15, 2007 12:30 pm Post subject: RE:C++ stack malfunctioning?
Have you tried defining the == operator for your new structure? I could be wrong, but I don't think it's supposed to provide one by default.
OneOffDriveByPoster
Posted: Sat Sep 15, 2007 5:22 pm Post subject: Re: RE:C++ stack malfunctioning?
Mazer @ Sat Sep 15, 2007 12:30 pm wrote:
Have you tried defining the == operator for your new structure? I could be wrong, but I don't think it's supposed to provide one by default.
Posted: Sat Sep 15, 2007 6:55 pm Post subject: RE:C++ stack malfunctioning?
IIRC the compiler will generate a compare function for any user defined types. What exactly does std::stack<>::top() return? Perhaps it's not returning what you think...
What's wrong with
c++:
struct point {int x, y; };
There is nothing I hate more then needless typedefs.
wtd
Posted: Sun Sep 16, 2007 2:43 am Post subject: RE:C++ stack malfunctioning?