Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not sure what is wrong with this !!!

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I hope someone can help me, because I'm really not sure what's wrong,
ok I have this class

class rational {
private:
int top;
int bottom;
void normalize();

public:
rational();
rational(int);
rational(int, int);
rational(rational&);
int numerator();
int denominator();
void operator = (rational&);
rational operator + (rational&);
rational operator - (rational&);
rational operator * (rational&);
rational operator / (rational&);
rational operator - ();
};

---now the error massage that I get is as follow:
error C2228: left of '.numerator' must have class/struct/union type

(**)error location

rational rational::eek:perator + (rational& right)
{
rational result;
** result.top = (this.numerator()*right.denominator() +
** right.numerator()*this.denominator());
** result.bottom = this.denominator()*right.denominator();
result.normalize();
return result;
}

thank you
 
this is a pointer so all the this. should be this->

Also, the rational& parameters should be const rational&.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top