delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/27/13:58:34

From: GAMMELJL AT SLU DOT EDU
Date: Mon, 27 Sep 1999 09:48:34 -0500 (CDT)
Subject: Re: problem with new malloc.c attn: Michael Bukin & Eli Zaretskii
To: djgpp AT delorie DOT com
Message-id: <01JGGKZ1SF0M8WW43D@SLU.EDU>
Organization: SAINT LOUIS UNIVERSITY St. Louis, MO
X-VMS-To: IN%"djgpp AT delorie DOT com"
MIME-version: 1.0
Reply-To: djgpp AT delorie DOT com

     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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019