I have two classes, Monomio (which represents a monom.. with its coefficient,and exponent) and Polinomio, which has a dynamic array of Monoms.
In Polinomio, i have declared this
private function
1 2 3 4 5 6 7 8 9 10
|
unsigned Polinomio::max(const unsigned& a,const unsigned& b)
{
if ( a > b){
return a;
}
else{
return b;
}
}
|
im using it on some operator overloads which are within the class (For example, operator + and operator - ) like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
bool Polinomio::operator==(const Polinomio& p) const
{
unsigned i = 0;
bool output = true;
unsigned tam = 0; //tam is the max size
//calculates max exponent plus one. That is the size of the biggest polinom
tam = max(this.at(length_-1).exp() +1,p.at(p.length()-1).exp()+1); // Something is wrong here
//compares both polinoms, monom to monom
while ((output==true)&&(i< tam)){
cout << "i = " << i << endl;
output = output&&( read(i) == p.read(i)); //Read(i) returns the monom
//of exponent i in its polinom
i++;
}
return output;
}
|
, i receive the following error:
In member function `bool Polinomio::operator==(const Polinomio&) const': `at' is not a type request for member of non-aggregate type before '(' token
if i remove this, then i receive passing
`const Polinomio' as `this' argument of `unsigned int Polinomio::max(const unsigned int&, const unsigned int&)' discards qualifiers
this.at(length_-1).exp() +1 should return an unsigned
p.at(i), where p is a polinom, return the monom in the i position of the array (be careful, is different to read(i) , but at works properly : i've tested it already)
m.exp() ,where m is a monom, returns the exponent of the monom, which is an unsigned
What is going on here?