The issue here is that a child interface can inherit from a parent interface. A child interface cannot inherit from itself. As noted previously, the derived interface must be unique and therefore have a different name.
The next update to PowerBASIC will generate a more descriptive exception report in this case.
Best regards,
Bob Zale
PowerBASIC Inc.
Announcement
Collapse
No announcement yet.
Possible to inherit implemenation of the same interface in a new class?
Collapse
X
-
Error 816 in C:\VDLTech\Berra\Tests\InheritTest2.bas(10:005): Internal system error
Line 10: END INTERFACE
Leave a comment:
-
You can, but changing the name of the second interface.
Code:'SED_PBCC #COMPILE EXE #DIM ALL 'I usually "publish" Interfaces that I can use outside the current file in the program's header. '(this way I know which interfaces are supposed to be implemented by the 'program and which interfaces I only created for internal use) INTERFACE IncredibleInterface INHERIT CUSTOM METHOD AAA() METHOD BBB() METHOD CCC() END INTERFACE 'Here I create class CTest1 that has the "default implementation" of above's IncredibleInterface interface. CLASS CTest1 INTERFACE IncredibleInterface INHERIT CUSTOM METHOD AAA() ? "AAA1" END METHOD METHOD BBB() ? "BBB1" END METHOD METHOD CCC() ? "CCC1" END METHOD END INTERFACE END CLASS 'Now I want to create class CTest2, which implements the IncredibleInterface just like CTest1. 'I want to override 1 of the methods though, this is the only Method which has its own implementation. CLASS CTest2 INTERFACE IncredibleInterface2 INHERIT CTest1,IncredibleInterface OVERRIDE METHOD BBB() ? "BBB2" END METHOD END INTERFACE END CLASS FUNCTION PBMAIN () AS LONG DIM CT1 AS IncredibleInterface DIM CT2 AS IncredibleInterface2 CT1 = CLASS "CTest1" CT1.AAA CT1.BBB CT1.CCC CT2 = CLASS "CTest2" CT2.AAA CT2.BBB CT2.CCC CT1 = NOTHING CT2 = NOTHING WAITKEY$ END FUNCTION
Leave a comment:
-
Possible to inherit implemenation of the same interface in a new class?
Hi there,
Let's hope I can make myself clear:
I have a single interface that I want to implement in different classes. The implementations of the interface in the classes are almost the same, only a few of the METHODs differ.
What I would like to do is the following:
Code:#COMPILE EXE #DIM ALL 'I usually "publish" Interfaces that I can use outside the current file in the program's header. '(this way I know which interfaces are supposed to be implemented by the 'program and which interfaces I only created for internal use) INTERFACE IncredibleInterface INHERIT CUSTOM METHOD AAA() METHOD BBB() METHOD CCC() END INTERFACE 'Here I create class CTest1 that has the "default implementation" of above's IncredibleInterface interface. CLASS CTest1 INTERFACE IncredibleInterface INHERIT CUSTOM METHOD AAA() ? "AAA1" END METHOD METHOD BBB() ? "BBB1" END METHOD METHOD CCC() ? "CCC1" END METHOD END INTERFACE END CLASS 'Now I want to create class CTest2, which implements the IncredibleInterface just like CTest1. 'I want to override 1 of the methods though, this is the only Method which has its own implementation. CLASS CTest2 INTERFACE IncredibleInterface INHERIT CTest1,IncredibleInterface OVERRIDE METHOD BBB() ? "BBB2" END METHOD END INTERFACE END CLASS FUNCTION PBMAIN () AS LONG DIM CT1 AS IncredibleInterface DIM CT2 AS IncredibleInterface CT1 = CLASS "CTest1" CT1.AAA CT1.BBB CT1.CCC CT2 = CLASS "CTest2" CT2.AAA CT2.BBB CT2.CCC CT1 = NOTHING CT2 = NOTHING WAITKEY$ END FUNCTION
PowerBASIC Console Compiler
PB/CC Version 5.01
Copyright (c) 1998-2009 PowerBasic Inc.
Venice, Florida USA
All Rights Reserved
Error 816 in C:\VDLTech\Berra\Tests\InheritTest2.bas(10:005): Internal system error
Line 10: END INTERFACE
The only solution I came up with is the following, but it's not really pretty IMHO, not to mention too much typing:
Code:#COMPILE EXE #DIM ALL 'I usually publish Interfaces that I use outside this file outside the class, like this: INTERFACE IncredibleInterface INHERIT CUSTOM METHOD AAA() METHOD BBB() METHOD CCC() END INTERFACE 'Here I create class CTest1 that has the "default implementation" of above's IncredibleInterface interface. CLASS CTest1 INTERFACE IncredibleInterface INHERIT CUSTOM METHOD AAA() ? "AAA1" END METHOD METHOD BBB() ? "BBB1" END METHOD METHOD CCC() ? "CCC1" END METHOD END INTERFACE END CLASS 'Nowe I want to create class CTest2, which implements the IncredibleInterface just like CTest1. 'I want to override 1 of the methods though, this is the only Method which its own implementation. CLASS CTest2 INSTANCE m_ct1 AS IncredibleInterface CLASS METHOD Create m_ct1 = CLASS "CTest1" END METHOD CLASS METHOD Destroy 'Yes, I know it's not neccessary, but I like to clean up my mess. m_ct1 = NOTHING END METHOD INTERFACE IncredibleInterface INHERIT CUSTOM METHOD AAA() m_ct1.AAA END METHOD METHOD BBB() ? "BBB2" END METHOD METHOD CCC() m_ct1.CCC END METHOD END INTERFACE END CLASS FUNCTION PBMAIN () AS LONG DIM CT1 AS IncredibleInterface DIM CT2 AS IncredibleInterface CT1 = CLASS "CTest1" CT1.AAA CT1.BBB CT1.CCC CT2 = CLASS "CTest2" CT2.AAA CT2.BBB CT2.CCC CT1 = NOTHING CT2 = NOTHING WAITKEY$ END FUNCTION
Best regards, VincentTags: None
Leave a comment: