You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
When you inherit one interface into another, I looks as if the instance variables *do not* get inherited. Is this the way it is supposed to work or am I missing something?
I guess they will need to be replaced with globals in this case as far as I can see.
When you inherit one interface into another, I looks as if the instance variables *do not* get inherited. Is this the way it is supposed to work or am I missing something?
I guess they will need to be replaced with globals in this case as far as I can see.
Your missing something.
It would help if you provided just a wee bit of code.
#Compile Exe
#Dim All
Class MyClass1
Instance x As Long
Interface MyInt1
Inherit IUnknown
Method DoubleX
x *= 2
End Method
Property Get VarX() As Long
Property = x
End Property
Property Set VarX(ByVal Invar As Long)
x = Invar
End Property
End Interface
End Class
Class MyClass2
Instance x As Long ' If this line is *not* here, you get "Missing declaration X" compiler error...
' If the line *is* there, then TrippleX does not work as expected...
Interface MyInt2
Inherit MyClass1, MyInt1
Method TrippleX
x *= 3
End Method
End Interface
End Class
Function PBMain () As Long
Local MyObj As MyInt2
MyObj = Class "MyClass2"
MyObj.VarX = 5
MyObj.TrippleX
? Format$(MyObj.VarX) ' Result should be 15, but is not...
End Function
...looks as if the instance variables *do not* get inherited.
Actually, there essentially aren't any such things as interface variables. Interfaces are actually memory blocks containing pointers to functions.
I actually myself haven't used the new PB compilers a great deal yet, but I stumbled over this issue at first too. In terms of other OOP languages inheritance of base class variables is supported to varying extents, for example in C++. However, the COM specification does not appear to allow for this, and PB likewise does not support it. Awhile back Kev Peel posted a work around for this which is pretty neat where properties instead of variables were used to transfer data between base and inheriting classes.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment