www.digitalmars.com         C & C++   DMDScript  

D - interface function not implemented

reply J C Calvarese <jcc7 cox.net> writes:
I'm getting a weird error from trying to compile a class based on an 
interface:

main.d: class FakeStorage interface function IStorage.SetClass is not 
implemented

Never mind the absense of a line number, I can find the IStorage 
interface ...

    extern(Windows)
    interface IStorage : IUnknown
    {
       //...

       HRESULT SetClass(REFCLSID clsid);
    }

... and I can find the FakeStorage class ...

    class FakeStorage : ComObject, IStorage {
       extern (Windows):

       HRESULT QueryInterface(IID* riid, void** ppv)
       {
          return E_NOTIMPL;
       }

       // ...

       HRESULT SetClass(REFCLSID clsid)
       {
          return S_OK;
       }

       // ...	
}


It looks SetClass looks pretty implemented to me. REFCLSID should be 
compatible with REFCLSID. Does anyone have any hints what my problem 
might be?

I've already tried abbreviating the offending code into a short example 
of the problem, but the error disappeared. I'll probably try again, but 
I thought someone might have a priceless hint that solves my problem. 
Thanks.


-- 
Justin
http://jcc_7.tripod.com/d/
Feb 24 2004
parent reply Julio CÚsar Carrascal <Julio_member pathlink.com> writes:
       HRESULT SetClass(REFCLSID clsid)
       {
          return S_OK;
       }

Why don't you use the "override" keyword? http://www.digitalmars.com/d/
Feb 25 2004
next sibling parent reply J Anderson <REMOVEanderson badmama.com.au> writes:
Julio CÚsar Carrascal wrote:

      HRESULT SetClass(REFCLSID clsid)
      {
         return S_OK;
      }
    

Why don't you use the "override" keyword? http://www.digitalmars.com/d/

before but never understood its use? -- -Anderson: http://badmama.com.au/~anderson/
Feb 25 2004
next sibling parent reply larry cowan <larry_member pathlink.com> writes:
http://www.digitalmars.com/advancedsearch.html

In article <c1icqr$1vlg$1 digitaldaemon.com>, J Anderson says...
Julio CÚsar Carrascal wrote:

      HRESULT SetClass(REFCLSID clsid)
      {
         return S_OK;
      }
    

Why don't you use the "override" keyword? http://www.digitalmars.com/d/

before but never understood its use? -- -Anderson: http://badmama.com.au/~anderson/

Feb 25 2004
parent J Anderson <REMOVEanderson badmama.com.au> writes:
larry cowan wrote:

http://www.digitalmars.com/advancedsearch.html

In article <c1icqr$1vlg$1 digitaldaemon.com>, J Anderson says...
  

Julio CÚsar Carrascal wrote:

    

     HRESULT SetClass(REFCLSID clsid)
     {
        return S_OK;
     }
   

        

http://www.digitalmars.com/d/

before but never understood its use? -- -Anderson: http://badmama.com.au/~anderson/


The *override* attribute applies to virtual functions. It means that the function must override a function with the same name and parameters in a base class. The override attribute is useful for catching errors when a base class's member function gets its parameters changed, and all derived classes need to have their overriding functions updated. For anyone else who wants a direct link: http://www.digitalmars.com/d/attribute.html I don't think then that the override is nessary, it's for error checking. -- -Anderson: http://badmama.com.au/~anderson/
Feb 25 2004
prev sibling parent =?ISO-8859-1?Q?Sigbj=F8rn_Lund_Olsen?= <sigbjorn lundolsen.net> writes:
J Anderson wrote:

 Julio CÚsar Carrascal wrote:
 
      HRESULT SetClass(REFCLSID clsid)
      {
         return S_OK;
      }
   

Why don't you use the "override" keyword? http://www.digitalmars.com/d/

before but never understood its use?

I don't see entirely why you should have to explicitly 'override' an interface function. It should be rather obvious that if a class derives from an interface the function cannot possibly have been defined before. Cheers, Sigbj°rn Lund Olsen
Feb 25 2004
prev sibling parent J C Calvarese <jcc7 cox.net> writes:
Julio CÚsar Carrascal wrote:

      HRESULT SetClass(REFCLSID clsid)
      {
         return S_OK;
      }

Why don't you use the "override" keyword? http://www.digitalmars.com/d/

Thanks for the suggestion. I hadn't tried that yet. Unfortunately, that just changes the error message: main.d(451): function SetClass function SetClass does not override any But then, I got it to work. I think I must have two REFCLSID's hanging around (with different definitions). So I re-created REFCLSID from scratch: struct jcc_GUID { align(1): DWORD Data1; WORD Data2; WORD Data3; BYTE Data4[8]; } alias jcc_GUID jcc_CLSID; alias jcc_CLSID* jcc_REFCLSID; I substituted jcc_REFCLSID for REFCLSID in both files and it worked! Woo-hoo! I'll have to look into the specifics later (so I don't get bit by this again), but hooray! The program compiles AND runs! -- Justin http://jcc_7.tripod.com/d/
Feb 25 2004