are virtual destructors in novtable interfaces okay?
<p>I have a Visual Studio 2008 C++03 project where I have an interface class that is declared <code>_declspec( novtable )</code>. For example:</p>

<pre><code>class _declspec( novtable ) IFoo
{
public:
    virtual void FooDo() const = 0;
};

class Foo : public IFoo
{
public:
    ~Foo() { printf( "~Foo()\r\n" ); };
    void FooDo() const { printf( "FooDo()\r\n" ); };
};

int main( int argc, char* argv[] )
{
    IFoo* foo = new Foo();
    foo-&gt;FooDo();
    delete foo;
    return 0;
}
</code></pre>

<p>Because <code>IFoo</code> does not have a virtual destructor, the concrete <code>Foo</code> destructor is never called.</p>

<p>Output:</p>

<pre><code>FooDo()
</code></pre>

<p>Desired Output:</p>

<pre><code>FooDo()
~Foo()
</code></pre>

<p>But, in <a href="http://msdn.microsoft.com/en-us/library/k13k85ky%28v=vs.71%29.aspx" rel="nofollow">MSDN</a>, there is a dire warning against calling functions in interface classes declared <code>novtable</code>. "<em>If you attempt to instantiate a class marked with novtable and then access a class member, you will receive an access violation (AV)</em>." So adding a <code>virtual ~IFoo() { };</code> member sounds like it could be a Bad Thing. (although in my testing, it seems to work fine.)</p>

<p>How does one properly get the desired behavior from this?</p>
