compilation error in C++
<p>I have the following code in C++ and I got the compilation error:</p>

<pre><code>a.cpp: In member function `virtual void Derived&lt;T, D&gt;::run(T&amp;)':
a.cpp:13: error: expected primary-expression before "int"
a.cpp:13: error: expected `;' before "int"
</code></pre>

<p>Please help me find out what went wrong here. Thanks a lot.</p>

<pre><code>#include &lt;iostream&gt;
template&lt;typename T&gt; struct Base
{
    virtual void run( T&amp; ){}
    virtual ~Base(){}
};

template&lt;typename T, typename D&gt; struct Derived : public Base&lt;T&gt;
{
    virtual void run( T&amp; t )
    {
        D d;
        d.operator()&lt;int&gt;();//nor does d.operator()&lt;T&gt;(); work
    }
};

template&lt;typename T&gt; struct X
{
    template&lt;typename R&gt;  X(const R&amp; r)
    {
       std::cout &lt;&lt; "X(R)" &lt;&lt; std::endl;
       ptr = new Derived&lt;T,R&gt;(); 
    }

    X():ptr(0)
    { 
        std::cout &lt;&lt; "X()" &lt;&lt; std::endl; 
    }

    ~X()
    {
        if(ptr) 
        {
            ptr-&gt;run(data);
            delete ptr;
        }
        else
        {
            std::cout &lt;&lt; "no ptr" &lt;&lt; std::endl;
        }
    }

    Base&lt;T&gt;* ptr; 
    T data;
};

struct writer
{
    template&lt;typename T&gt; void operator()()
    { 
        std::cout &lt;&lt; "T "&lt;&lt; std::endl;
    }
};

int main()
{
    {
        writer w;
        X&lt;int&gt; xi1((writer()));
    }
    return 0;
};
</code></pre>
