Mail Archives: djgpp/1999/09/27/13:58:34
When I try adding the line
zvector &operator= (zvector &);
to my definition of class zvector I get error messages which I am unable
to use due to lack of knowledge.
Rather than dealing with the intracacies of overloading the
assignment operator, I can overload the operator < and use it as an
assignment operator. I add the overload
void operator<(zvector w8,zvector w9)
{int zi;
for (zi=1;zi<length+1;zi++)
{w8.s[zi+1]=w9.s[zi+1];}
}
just below the overload of operator+ and then write
g<e+f; //instead of g=e+f;
and
g<f+e; //instead of g=f+e;
and that all goes fine SO LONG AS I delete the destructor ~zvector
in the definition of class zvector and also the definition of ~zvector.
In other words, everything is as before.
I know that it is a ridiculous request, but I would like to know
how to overload operator= and I would like to know the solution to my
problem. I understand that my code contains some error which, as
both of you have pointed out, arises from the properties of free.
Please write out the correct code for me--it is only a few lines.
The overloading of operator= is a side issue but I may as well learn
that.
- Raw text -