Classes of objects c++
<p>I'm a beginner in C++ but know object oriented programming..</p>

<p>I have a class that has some objects of different classes.</p>

<pre><code>class machine{
public:
    int func();
private:
    Plug p;
    std::vector&lt;Rot&gt; r;
    Ref ref;
};
</code></pre>

<p>Is this the correct way to do it? The reason I'm not so sure is because if I do something like <code>cout &lt;&lt; this-&gt;r.size()</code> in <code>func</code> it doesn't output anything (I have the right includes and namespaces). The compiler compiles it but the program says <code>run failed</code>. No further messages. I'm using the latest Cygwin compiler g++ compiler.</p>

<p><strong>Edit</strong>: I'm just trying to make sure that this is the correct way to define a member object of a class. So <code>Plug p;</code> : is that correct? Because if I call a method in the <code>Plug</code> class from within <code>machine</code>, it doesn't work like it works when I call a Plug method in <code>main()</code>. Moreover, the program exits with a fail when I do something with <code>r</code> (the <code>vector</code>)... Do I somehow have to call their constructors? If so, how do I do that?</p>

<p>Thanks for your help.</p>
