Inheritance and Implicit Type Casting
<p>Suppose I have the following three classes:</p>

<pre><code>class Animal {};

class Human : public Animal {};

class Dog : public Animal
{
public:
   void setOwner(Animal* owner) { this-&gt;owner = owner; }
private:
   Animal* owner;
};
</code></pre>

<p>Why is the following allowed, and what exactly is happening?</p>

<pre><code>Dog d;
Human h;

d.setOwner(&amp;h); // ?
</code></pre>

<p>At first, I tried to cast it like this <code>d.setOwner(&amp;(Animal)h)</code>, but the compiler gave me a warning, and I hit a run-time error.</p>

<p><strong>Edit</strong>: the warning the compiler gave me was "taking address of temporary". Why is this so?</p>
