title: Declaring an object with a parameterized constructor inside another class C++
body: <p>I wish to have an object of one class contained inside a different class.</p>
  <p>class A contained inside class B as in the simple example below.</p>
  <p>The problem is that class A only has a parametrized constructor.</p>
  <p>Is there another way to do declare the class A object in class B without having to use a pointer to class A ?</p>
  <pre><code>class A
  {
      public:
          A(int var1, int var2);
      private:
          //...
  };
  
  class B
  {
      public:
          B();
      private:
          A  a;      // Compiler error 
          A* a_ptr; // This will of course work fine. We can create a new A object with parameters any time using the a_ptr
  };
  </code></pre>