title: need a virtual template member workaround
body: <p>I need to write a program implementing the visitor design pattern. The problem is that the base visitor class is a template class. This means that BaseVisited::accept() takes a template class as a parameter and since it uses 'this' and i need 'this' to point to the correct runtime instance of the object, it also needs to be virtual.<br>
  I'd like to know if there's any way around this problem.</p>
  
  <pre><code>template &lt;typename T&gt;
  class BaseVisitor {
    public:
      BaseVisitor();
      T visit(BaseVisited *visited);
      virtual ~BaseVisitor();
  }
  
  
  class BaseVisited {
    BaseVisited();
    template &lt;typename T&gt;
      virtual void accept(BaseVisitor&lt;T&gt; *visitor) { visitor-&gt;visit(this); }; // problem
    virtual ~BaseVisited();
  }
  </code></pre>