How are UML model relationships coded in C++?
<p>This question is in my exam revision, and I'm wondering if I'm on the right track with it, It is from the C++ primer text book.</p>

<p><strong>How are UML model relationships coded in C++?</strong></p>

<p>Public inheritance allows you to model IS-A relationships, with derived classes being able to reuse code of base classes. Another approach is to use containment, which is the relationship between objects where one object owns or has the other object. This models HAS-A relationships. </p>

<p>For example:</p>

<ul>
<li>Car has or owns Motor </li>
<li>When Car is built, it's motor is also built</li>
<li><p>When Car is destroyed, its motor is also destroyed.</p>

<pre><code>class Car 
{
    private:
        Motor *motor;
    public:
        Car()
        { 
             motor = new Motor(); 
        }

        ~Car() 
        { 
             delete motor; 
        }
};
</code></pre></li>
</ul>
