Thread overview
interface function not implemented
Feb 25, 2004
J C Calvarese
Feb 25, 2004
J Anderson
Feb 25, 2004
larry cowan
Feb 26, 2004
J Anderson
Feb 26, 2004
J C Calvarese
February 25, 2004
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/
February 25, 2004
>       HRESULT SetClass(REFCLSID clsid)
>       {
>          return S_OK;
>       }


Why don't you use the "override" keyword?

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


February 25, 2004
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/
>
>  
>
Where is that listed in the documention?  I've seen the override keyword before but never understood its use?


-- 
-Anderson: http://badmama.com.au/~anderson/
February 25, 2004
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/
>>
>> 
>>
>Where is that listed in the documention?  I've seen the override keyword before but never understood its use?
>
>
>-- 
>-Anderson: http://badmama.com.au/~anderson/


February 25, 2004
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/
>>
>>  
>>
> Where is that listed in the documention?  I've seen the override keyword 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
February 26, 2004
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/
February 26, 2004
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;
>>>>     }
>>>>   
>>>>
>>>>        
>>>>
>>>Why don't you use the "override" keyword?
>>>
>>>http://www.digitalmars.com/d/
>>>
>>> 
>>>
>>>      
>>>
>>Where is that listed in the documention?  I've seen the override keyword 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/