copy constructor error. please help
<p>I need someone to show me what is wrong with this code. I don't know what's wrong with it. I know the code doesn't do anything meaningful and it can't be used. I created it only to know how copy constructors work. Please, I need some "for newbie" explanation. </p>

<pre><code>class test
{
  public:

    int* value;

  public:

    int getvalue()
    {return *value;};

    test(int x){ value = new int(x);};

    test(const test&amp; a)
    {
        value=new int;

        *value = a.getvalue();
    };
};
</code></pre>

<h3>Edit (copied from self answer below)</h3>

<p>I tried making the getvalue() function const and it worked. The problem was that I passed the test class as a const reference and because I didn't declare the getvalue() function const the compiler thought the function was going to change something in that reference. Am I wrong? </p>
