title: What is the correct syntax in C++ for calling a method stored inside of a class using a different class as the 'this' for the method?
body: <p>I have a template class like this:</p>
  
  <pre><code>class template &lt;class T1, class T2, class CTHIS&gt; class cachedValuesClass
  {
  typedef T2 (CTHIS::*ptrToInternalMethodType)(T1) const;
  ptrToInternalMethodType classFuncVar;
  T2 getValue(CTHIS* _this, T1 x, bool *error = NULL) const;
  }
  </code></pre>
  
  <p>The getValue code is supposed to call for the method stored at the point this->classFuncVar using the _this parameter as the "this" for this call. I tried writing this:</p>
  
  <pre><code> template &lt;class T1, class T2, class CTHIS&gt;
   T2 cachedValuesClass&lt;T1, T2, CTHIS&gt;::getValue(CTHIS* _this, T1 x, bool *error /*=NULL*/) const
   {
   return *_this.*this.*classFuncVar(x);
   }
  </code></pre>
  
  <p>But it doesn't work, I get this error:</p>
  
  <pre><code> 130|error: must use ‘.*’ or ‘-&gt;*’ to call pointer-to-member function in ‘((const cachedValuesClass&lt;float, float, vocationForTheorical&gt;*)this)-&gt;cachedValuesClass&lt;float, float, vocationForTheorical&gt;::classFunc (...)’, e.g. ‘(... -&gt;* ((const cachedValuesClass&lt;float, float, vocationForTheorical&gt;*)this)-&gt;cachedValuesClass&lt;float, float, vocationForTheorical&gt;::classFunc) (...)’|
   130|error: ‘this’ cannot be used as a member pointer, since it is of type ‘const cachedValuesClass&lt;float, float, vocationForTheorical&gt;* const’|
  </code></pre>
  
  <p>I tried several variations, including parenthesis but I coudn't make it work.
  How should be correct syntax for this line?</p>
  
  <p>Thanks in advance!</p>