class monomial
{
public:
monomial(){};
monomial(string vars);
// Assignment operator
void operator= (monomial & p);
monomial operator* ( monomial &p);
monomial operator/ (monomial &p);
bool operator== ( monomial &p) ;
bool operator> ( monomial &p) ;
bool operator< ( monomial &p) ;
void print();
public:
list<unsigned int> var;//variables separated by ":"
};
The code in main:
monomial a1("a:b:c");
monomial a2("a:c");
monomial a8;
a8=a1/a2
a8.print();
cout<<endl;
After compilation, I run it and got an error message:
no match for ‘operator=’ in ‘a8 = monomial::operator+(monomial&)(((monomial&)(& a2)))’.
Well, when I changed the declaration of assignment
void operator= (monomial & p);
to
void operator= (monomial p);
everything is fine.
I just cannot understand why?
I also tried it in visual studio and it works perfect.
thanks
gepo