Announcement

Collapse
No announcement yet.

Inheritance Use Question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Inheritance Use Question

    Using Direct Interface Block definitions with Classes, and am running into an error when utilizing a "UserWritten" Inherit statement in a Direct Interface Block.

    The Error, a "CLASS Expected" error associated with the use of an Inherit Statement in a Direct Interface Block, does not occur when the Direct Interface Block is excluded. (Though the same "UserWritten" Inherit Statement is still included in the derived Class implementation code.)

    Example Code:
    Code:
       INTERFACE CLASS1Interface
          INHERIT IUNKNOWN
    
          Method aRoutine() as Long
    
       END INTERFACE
    
    CLASS CLASS1
       INTERFACE CLASS1Interface
          INHERIT IUNKNOWN
    
          Method aRoutine() as Long
          End Method
    
       END INTERFACE
    END CLASS
    
    'Code compiles as shown with the Direct
    'Interface Block below commented out.  However, 
    'if conditional Direct Interface Block 
    'below is [u]included[/u] in the compile,
    'changing #if(0) to #if(1), then the
    'compiler complains...
    ' "CLASS Expected"
    ' Compiler complains about the 
    ' inheritance ONLY with the 
    ' Direct Interface Block below active.
    '--
    [color=blue]
    #if(0)  
       INTERFACE CLASS2Interface
          [b]INHERIT CLASS1, CLASS1Interface[/b]  '<-Not Happy
    
          Method aTest() as Long
    
       END INTERFACE
    #endif
    [/color]
    
    CLASS CLASS2
       INTERFACE CLASS2Interface
          [b]INHERIT CLASS1, CLASS1Interface[/b]   '<- Happy
          
          Method aTest() as Long
          End Method
    
       END INTERFACE
    END CLASS
    
    
    function pbmain()
       waitkey$
    end Function
    It other words, it (the compiler) is happy with "INHERIT CLASS1, CLASS1Interface" as implementation code but not as definition code that is part of a Direct Interface Block. Any insights as to why the Inherit Statement "INHERIT CLASS1, CLASS1Interface" compiles happily until a Direct Interface Block definition is included?
Working...
X