Use of const, get paremeter NOT by-copy
<p>I wrote this code:</p>

<pre><code>class Address{

  private:
    std::string street;
    int house;

  public:
    Address(std::string s, int h):
      street(s), house(h) {}

    void setHouse(int h) {house = h;}

    friend std::ostream &amp;operator &lt;&lt; (std::ostream&amp; os, Address &amp;a);
};

class Person{

    private:
      std::string name;
      Address A;

    public:
      Person(std::string n, std::string v, int c) :
        name(n), A(v, c) {}

      Address&amp; getAddress(){return A;}

    friend std::ostream &amp;operator &lt;&lt; (std::ostream&amp; os, Person &amp;a);

};

std::ostream &amp;operator &lt;&lt; (std::ostream&amp; os, Address &amp;a){

  return os &lt;&lt; "[" &lt;&lt; a.street &lt;&lt; ", " &lt;&lt; a.house &lt;&lt; "]";
}

std::ostream &amp;operator &lt;&lt; (std::ostream&amp; os, Person &amp;p){

  return os &lt;&lt; p.name &lt;&lt; " " &lt;&lt; p.A;
}

int main(){

  Person pietro("Pietro", "Champs Elysees", 16);

  std::cout &lt;&lt; pietro &lt;&lt; std::endl;

  Address ma = pietro.getAddress();
  ma.setHouse(333); 

  std::cout &lt;&lt; pietro &lt;&lt; std::endl;

  return EXIT_SUCCESS;
}
</code></pre>

<p>I have these questions:</p>

<ol>
<li>Why does the line <code>ma.setHouse(333);</code> does not have any side effect on <code>pietro</code> (ie in the second print the house-number is not changed)?</li>
<li>(I know that it's not the right way, but) how can i make <code>ma.setHouse(333);</code> having side effects on <code>pietro</code> ?</li>
<li>Why should i write <code>const Address&amp; getAddress() const {return A;}</code> if the above code does not have side effects?</li>
</ol>
