Polynomial Class Crashes While Handling overloaded operator=
<p>I am working on a program that derives a Polynomial class from a Function class.  I am almost complete, but I'm running in to one last problem.</p>

<p>I am invoking an "=" operator. In function main, it looks like this:</p>

<pre><code>f3 = f2 * 2;
</code></pre>

<p>f3 and f2 are both Polynomial data types.  The multiply operator is overloaded, as well, and has been tested to work.  When my program reaches this point, it crashes. Here is the backtrace of the crash:</p>

<pre><code>Program received signal SIGABRT, Aborted.
0x00000000 in ?? ()
(gdb) bt
#0  0x00000000 in ?? ()
#1  0x77cbf8c1 in ntdll!RtlUpdateClonedSRWLock ()
   from /cygdrive/c/Windows/system32/ntdll.dll
#2  0x75ab0816 in WaitForSingleObjectEx ()
   from /cygdrive/c/Windows/syswow64/KERNELBASE.dll
#3  0x000000ec in ?? ()
#4  0x00000000 in ?? ()
</code></pre>

<p>Unfortunately, that does not provide me any hints.</p>

<p>Lastly, here is the overloaded operator=:</p>

<pre><code>    Polynomial&amp; Polynomial::operator=(const Polynomial&amp; rhs) {
if(this-&gt;a)
    delete [] this-&gt;a;
this-&gt;setName(rhs.getName());
this-&gt;degree = rhs.degree;
a = new double[this-&gt;degree];
for(int i = 0; i &lt; this-&gt;degree; i++)
{
    this-&gt;a[i] = rhs.a[i];
}
return *this;
}
</code></pre>

<p>And the header file for the class.</p>

<pre><code>    class Polynomial : public Function
{
    public:
                    Polynomial (const string&amp; name = "unnamed");
                    Polynomial (const Polynomial&amp; rhs);
        void        setCoefficients (int degree, ...);
        int         getDegree() const { return degree; }
        double      operator[] (int i) const;
        double      operator() (double x) const;
        Polynomial  operator* (double c) const;
        Polynomial&amp; operator*= (double c);
        Polynomial&amp; operator=(const Polynomial&amp; rhs);
        void        write(ostream&amp; outfile) const;

    private:
        double*    a;
        int        degree;
};
Polynomial operator* (double c, const Polynomial&amp; p);
</code></pre>

<p>Constructors:</p>

<pre><code>   (Polynomial::Polynomial (const string&amp; name) {
    a = new double[1];
    a[0] = 0;
    degree = 0;
    return;
    }

Polynomial::Polynomial (const Polynomial&amp; rhs) {

    //Null a, and then pass over to the overloaded = operator.
    if(this-&gt;a)
        delete [] this-&gt;a;
    *this = rhs;
    return;
    }
</code></pre>

<p>I'm willing to share as much code as necessary. Thank you for any help!</p>
