-
operator overloding bug
Can you help me with this nasty bug please?
stonewt.cpp:128: no `class Stonewt Stonewt::operator +(const Stonewt &) const' member function declared in class `Stonewt'
Code:
Stonewt Stonewt::operator+(const Stonewt & b) const
{
switch (mode)
{
case 'i' : return Stonewt(ipounds+b.ipounds);
break;
case 'p' : return Stonewt(pounds+b.pounds,'p');
break;
case 's' : return Stonewt(stone+b.stone,pds_left+b.pds_left);
break;
}
}
-
It's not a bug, it's a syntax error :).
Anyway, it seems like you've forgotten to declare the function (method) in your class prototype.
Code:
class Stonewt
{
public:
Stonewt Stonewt::operator+(const Stonewt & b) const;
...
};