title: c++ initialize template class constructor
body: <p>How do I initialize pointer class B <code>foo</code> inside class A? I am new to C++.</p>
  
  <p>Header.h</p>
  
  <pre><code>namespace Core
  {
      enum type
      {
          Left, Right
      };
  
      template&lt;type t&gt;
      class B
      {
      public:
          B(int i);
      private:
          type dir;
          int b = 12;
      };
  
      class A
      {
      public:
          B&lt;Left&gt; *foo;
      };
  }
  </code></pre>
  
  <p>Source.cpp</p>
  
  <pre><code>namespace Core
  {
      template&lt;type t&gt;
      B&lt;t&gt;::B(int i)
      {
          dir = t;
          b = i;
      }
  }
  
  int main()
  {
      Core::A *a = new Core::A;
      a-&gt;foo = new Core::B&lt;Core::Left&gt;(10);
  
      return 0;
  }
  </code></pre>