What is wrong with this c++ code?
<p>As you can see I am new to C++, but I can't understand why <code>y = new Person()</code> in function <code>foo</code> is wrong. Thanks for your help.</p>

<p>I get the this error:</p>

<blockquote>
  <p>error: no match for ‘operator=’ in ‘y = (((Person*)operator new(32u)),
  (, ))’</p>
</blockquote>

<h2>UPDATE:</h2>

<p>I will accept the answer with the most upvotes by tonight or the one that is more convincing. </p>

<p><strong>The argument between me and my friend is wether the function foo can change the object and propagate the change outside the function like when doing <code>y = Person()</code>, then also <code>brother</code> will change or will it remain intact?</strong>
.</p>

<h2>CODE:</h2>

<pre><code>#include &lt;iostream&gt;
using namespace std;

 class Person {
   public:  
    int age;
    char name[25];

    Person() {
            age = 0;

    }
};

void foo(Person &amp;y)
{
    y = new Person();
}

int main()
{
    Person *brother = new Person();
    brother-&gt;age = 20;

    cout &lt;&lt; "age = " &lt;&lt; brother-&gt;age &lt;&lt; endl;
    foo(*brother);
    cout &lt;&lt; "age = " &lt;&lt; brother-&gt;age &lt;&lt; endl;
    return 0;
} 
</code></pre>
