operator overloding bug

This is a discussion on operator overloding bug within the C++ Programming forums, part of the General Programming Boards category; Can you help me with this nasty bug please? stonewt.cpp:128: no `class Stonewt Stonewt::operator +(const Stonewt &) const' member function ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    95

    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;
                                 
          } 
    }

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    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;
    
       ...
    
    };
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Zooming Algorithm Bug
    By stuffy_boiz in forum C Programming
    Replies: 2
    Last Post: 01-19-2009, 02:34 AM
  2. gaks bug?
    By Yarin in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-31-2008, 03:47 PM
  3. Debugging a rare / unreproducible bug..
    By g4j31a5 in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 08-05-2008, 01:56 PM
  4. Another link from Microsoft about bug in fread
    By vart in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 05-06-2008, 12:56 PM
  5. ATL bug of CComPtr?
    By George2 in forum Windows Programming
    Replies: 6
    Last Post: 04-07-2008, 08:52 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21