constructor of the class containing another class as member variables
<p>I am try to make a class containing another class as member variable. And I encounter the follow problem:</p>

<pre><code>class SubClass{
    ....
};

class MainClass{
   public:
    MainClass(SubClass const &amp; subClass_);
   private:
    SubClass subClass
};
</code></pre>

<p>and in the .cpp files for the constructor</p>

<pre><code>MainClass::MainClass(SubClass const &amp; subClass_){
   subClass =  subClass_;
}
</code></pre>

<p>This gives out compiler errors. But the following works:</p>

<pre><code>MainClass::MainClass(SubClass const &amp; subClass_):
   subClass(subClass_) {}
</code></pre>

<p>Could anyone tell me what is the difference of these two? </p>

<p>Thanks!</p>
