Passing template class as parameter to class method and using template class as vector template type
<p>It has been a while since I have used templates with C++, but now I really need them.</p>

<p>I reproduced a problem I am having and I don't remember how the solution actually went. </p>

<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;

namespace problem {
    template &lt;typename T&gt;
    class data {
        public:
            inline data(T var) {
                this-&gt;var = var;
            }
        private:
            T var;
    };

    class storage {
        public:
            inline void push(problem::data&lt;T&gt; * data) {
                this-&gt;VData.push_back(data);
            }
        private:
            std::vector&lt;problem::data&lt;T&gt; *&gt; VData;
    };
};

int main() {
    problem::storage * testStorage = new problem::storage();
    problem::data&lt;int&gt; * testData = new problem::data&lt;int&gt;(256);

    testStorage-&gt;push(testData);

    delete testData;
    delete testStorage;
    return 0;
}
</code></pre>

<p>g++ -Wall problem.cpp gives me the following errors. </p>

<pre><code>problem.cpp:17:35: error: ‘T’ was not declared in this scope
problem.cpp:17:36: error: template argument 1 is invalid
problem.cpp:21:30: error: ‘T’ was not declared in this scope
problem.cpp:21:31: error: template argument 1 is invalid
problem.cpp:21:34: error: template argument 1 is invalid
problem.cpp:21:34: error: template argument 2 is invalid
problem.cpp: In member function ‘void problem::storage::push(int*)’:
problem.cpp:18:17: error: request for member ‘push_back’ in ‘((problem::storage*)this)-&gt;problem::storage::VData’, which is of non-class type ‘int’
problem.cpp: In function ‘int main()’:
problem.cpp:29:28: error: no matching function for call to ‘problem::storage::push(problem::data&lt;int&gt;*&amp;)’
problem.cpp:29:28: note: candidate is:
problem.cpp:17:16: note: void problem::storage::push(int*)
problem.cpp:17:16: note:   no known conversion for argument 1 from ‘problem::data&lt;int&gt;*’ to ‘int*’
</code></pre>

<p>I know I can use member templates, but what I do with the vector?</p>

<pre><code>template &lt;typename T&gt;
inline void push(problem::data&lt;T&gt; * data) {
    this-&gt;VData.push_back(data);
}
</code></pre>

<p>If I use the member template then the vector definition will leave these errors. </p>

<pre><code>problem.cpp:22:30: error: ‘T’ was not declared in this scope
problem.cpp:22:31: error: template argument 1 is invalid
problem.cpp:22:34: error: template argument 1 is invalid
problem.cpp:22:34: error: template argument 2 is invalid
problem.cpp: In member function ‘void problem::storage::push(problem::data&lt;T&gt;*)’:
problem.cpp:19:17: error: request for member ‘push_back’ in ‘this-&gt;.VData’, which is of non-class type ‘int’
</code></pre>
