Thread: operator function overloads

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    12

    operator function overloads

    using this class im trying to implement functions prototypes

    here:

    class Length
    {
    public:
    Length ();
    ~Length ();

    void setLength (int yards, int feet, int inches);
    int getYards();
    int getFeet();
    int getInches();

    private:
    int m_yards;
    int m_feet;
    int m_inches;
    };

    there is the class and here is the function prototypes

    Length operator+(length right);
    Length operator= (lenght right);
    Length operator>(lenght right);
    Length operator< (lenght right);

    and all i need is to implement the function prototypes:

    this is what i tryed but failed maybe you guys can see my mistakes------

    Length Length:perator+ (Length right);
    {
    int answers;
    answers = m_yards + m_feet + m_inches
    return Length(answer);
    }

    Length &Length:perator= (Length right);
    {
    if(this !& right)
    {
    setLength(right.m_yards, right.m_feet, right.m_inches);
    }
    return *this;
    }

    bool Length:perator>(length right)
    {
    if (getyards () >right.getyards())
    return true;
    else
    return false;
    }
    { if (getfeet() > right.getfeet());
    return true;
    else
    return false;
    }

    { if (getinches () > right.getinches());
    return true;
    else
    return false;
    }

    bool Length:: operator< (Lengths right)
    {
    if ( getyards () < right.getyards());
    return true;
    else
    return false;
    }

    { if (getfeet () < right.getfeet());
    return true;
    else
    return false;
    }

    { if (getinches() < right.getinches());
    return true;
    else
    return false;
    }


    //thats all i have so far and its not right so im looking for any input to the solution of this problem i hope i supplied you people with enought info to figure out what im doing..

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    12
    i have no idea why the smily faces are in there but where teh smily is its supposed to be


    : 0 i dont know whats up with that
    Im not the smartest but i try

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stream / bitshift overloads
    By Trauts in forum C++ Programming
    Replies: 1
    Last Post: 05-17-2003, 06:58 PM
  2. Templates AND operator overloads
    By Trauts in forum C++ Programming
    Replies: 2
    Last Post: 04-08-2003, 01:39 PM
  3. overloaded on overloads
    By emceedee in forum C++ Programming
    Replies: 1
    Last Post: 03-31-2003, 02:14 AM
  4. Operator Overloads and more?
    By Trauts in forum C++ Programming
    Replies: 1
    Last Post: 02-05-2003, 07:55 PM
  5. Replies: 3
    Last Post: 12-06-2002, 10:02 AM