www.digitalmars.com         C & C++   DMDScript  

D.gnu - abstract classes

been trying to use abstract classes to implement my templated module for
automatic QueryInterface generation .....
is there a reason that an abstract class can no have methods

import com;

abstract class L8ComObject : ComObject, IClassFactory {
  HRESULT QueryInterface(IID* riid, void** ppv) {
   return E_NOTIMPL;

causes the error
testif1.d(6): function QueryInterface abstract functions cannot have bodies


import com;

abstract class L8ComObject : ComObject, IClassFactory {

testif2.d: class L8ComObject interface function IClassFactory.CreateInstance
not implemented

surely abstract classes can have methods, but never be instantated, and I
see no reason why I can not have an abstract class than implements an
interface etc ....
this basically forces me to use concrete classes if implementing interfaces
with some default function (that just returns E_NOTIMPL)
seems to me the compiler can create one method that does than and fill all
the vtbls for me a lot easier than me doing it in my base class, and then
HRESULT func( params) { return super.func( params); }
in every class until the one that actually has any real code, which will
mean my templates will create 100's of copies of the same func and loads of
or everytime I want to create a COM interface I have to c'n'p my
QueryInterface and run the usual risks of errors, with worst being that I
  if ( *riid == IID_ISomethingIdontImplement ) {
   *ppv = (ISomethingIdontImplement)this;
   return S_OK;
which will return null in ppv .... arrgh! robustness out the window in one
I know I can use assert( !((rv == S_OK)&&(*ppv == null)) ) as an out
condition but that requires good correct testing of the debug version and
may not show up for sometime.
Aug 02 2003