title: c++ In member initialization pass new object in constructor
body: <p>In initializing the member variable theOtherThing below, the OtherThing class has a constructor that takes an object of type "Line", but I'm not passing an argLine through SomeClass' constructor. I want to declare a new Line object in the constructor, but I don't know how. I guess I could initialize it in the body of the constructor, and maybe I'm trying to be too slick.  </p>
  
  <pre><code>SomeClass::SomeClass(const Polygon&amp; argPoly,
                       const Point&amp;   argPoint)
                       //No argLine being passed here
     :
        thePolygon           (argPoly),
        thePoint             (argPoint),
        theOtherThing        (new OtherThing(Line())), //Something like this 
                             //But, the above does not work
                             //Nor (new OtherThing(Line aLine))
                             //Nor (new OtherThing(new Line())         
  {}
  </code></pre>
  
  <p>OtherThing class has a constructor that takes an object of type "Line"</p>
  
  <pre><code>OtherThing::OtherThing(const Line&amp; argLine)
     :
        theLine              (argLine)
  {}
  </code></pre>
  
  <p>Line has a default constructor that initializes its data members.</p>
  
  <pre><code>Line::Line()
  {
    //Data members get initilized here
  }
  </code></pre>
  
  <p>How do I do this? Maybe I'm over complicating it.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Declaration of theOtherThing:</p>
  
  <pre><code>Private :
     OtherThingPtr theOtherThing //It's an implementaion of C++ std::shrd_ptr
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>Line Class</p>
  
  <pre><code>class Line
  {
  public:
     double this;
     double that;
     Line();
     ... some other constructors and methods 
  }
  </code></pre>
  
  <p>OtherThing Class</p>
  
  <pre><code>class OtherThing : RefCountedObj
  {
  public:
     OtherThing(const Line&amp; argLine)
  
  private:
     Line  theLine;
     ...
  }
  </code></pre>