title: Copy Constructor and memory allocation
body: <p>Why is the memory address of message.pmessage the same before and after the constructor is called? Shouldn't the memory address of message.pmessage be different if it was allocated with new? I'm confused. </p>
  
  <p><strong>Overloaded Operator function</strong></p>
  
  <pre><code>CMessage operator+(const CMessage&amp; aMess) const
      {
        cout &lt;&lt; "Add operator function called." &lt;&lt; endl;
        size_t len = strlen(pmessage) + strlen(aMess.pmessage) + 1;
        CMessage message;
  
        //
        cout &lt;&lt; &amp;message.pmessage &lt;&lt; endl;
        cout &lt;&lt; message.pmessage &lt;&lt; endl;
        message.pmessage = new char[len];
        message.test = new char[len];
        cout &lt;&lt; &amp;message.pmessage &lt;&lt; endl;
        //
  
        strcpy_s(message.pmessage, len, pmessage);
        strcat_s(message.pmessage, len, aMess.pmessage);
        return message;
      }
  </code></pre>
  
  <p><strong>Constructor</strong></p>
  
  <pre><code>CMessage(const char* text = "Default message")
  {
    cout &lt;&lt; "Constructor called." &lt;&lt; endl;
    pmessage = new char[strlen(text) + 1];         // Allocate space for text
    strcpy_s(pmessage, strlen(text)+1, text);      // Copy text to new memory
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/kIQfL.png" alt="enter image description here"></p>