title: Detect the the vtable index/ordinal of a specific virtual function (using Visual C++)
body: <p>Further to my question: <a href="https://stackoverflow.com/questions/5590015/detect-the-the-vtable-offset-of-a-specific-virtual-function-using-visual-c">Detect the the vtable offset of a specific virtual function (using Visual C++)</a>:</p>
  
  <p>Given:</p>
  
  <pre><code>struct A 
  {
     virtual void a() {}
     virtual void b() {}
     virtual void c() {} 
  };
  </code></pre>
  
  <p>How can I write a function in Visual C++ (probably non-portable), such that:</p>
  
  <pre><code>int x = GetVtableIndex(&amp;A::a); //returns 0
  int x = GetVtableIndex(&amp;A::b); //returns 1
  int x = GetVtableIndex(&amp;A::c); //returns 2
  </code></pre>
  
  <p>Reasons why I'd want to do this are in the linked question.</p>