interface

Does interface delegation of an inherited interface require a wrapper class?

混江龙づ霸主 提交于 2019-12-20 01:43:49
问题 Delphi allows for interface delegation using the implements keyword. For example IIndep1 = interface function foo2: integer; end; IIndep2 = interface function goo2: integer; end; TIndep1And2 = class(TInterfacedObject, IIndep1, IIndep2) private FNested : IIndep1; //e.g. passed via constructor or internally created (not shown here) public Constructor Create(AIndep1: IIndep1); function goo2: integer; property AsIndep1 : IIndep1 read FNested implements IIndep1; end; That works well, but not for

How to check if a class implements an interface, with respecting supersets?

核能气质少年 提交于 2019-12-20 01:05:59
问题 I am learning about COM and Interfaces and have following experimental code: type IA = interface(IInterface) ['{C9C5C992-3F67-48C5-B215-7DCE6A61F0E8}'] end; IB = interface(IA) ['{F1799437-AD12-471B-8716-F1D93D1692FC}'] end; IC = interface(IB) ['{01780E8C-C47D-468E-8E42-4BFF3F495D51}'] end; TBO = class(TInterfacedObject, IB) end; procedure TForm1.FormCreate(Sender: TObject); var x: TBO; a: IInterface; begin x := TBO.Create; IInterface(x)._AddRef; if Assigned(TBO.GetInterfaceEntry(IA)) then

How to expose a method in an interface without making it public to all classes

牧云@^-^@ 提交于 2019-12-20 01:05:31
问题 I have a issue where I'm working with a particular interface for quite a lot of things. However, I have a particular method that I want to be available only to a particular group of classes (basically, an internal method). interface IThing { function thisMethodIsPublic():void; function thisMethodShouldOnlyBeVisibleToCertainClasses():void; } The problem is, there is no way to add access modifiers (i.e. public, private, internal) in an interface - at least not in ActionScript 3.0. So I'm

Is 'Strategy Design Pattern' no more than the basic use of polymorphism?

守給你的承諾、 提交于 2019-12-19 19:45:04
问题 In Strategy Design Pattern , what we do is Create a common interface. Implement a set of classes using that interface with overridden method(s). Let the run time to choose the actual class for an object which has the same type with that common interface and call the overridden method(s) which will resolve correctly according to the class. My question is, Isn't it the basic example of polymorphism and method overriding we learn? other than the possibility of using an abstract class too,

Can I overload pure virtual method in the base class?

家住魔仙堡 提交于 2019-12-19 19:43:19
问题 In the example below I have a abstract class with pure virtual method (aka FUN1) and a normal method (aka FUN2). #include <iostream> class A { public: virtual void fun(int i) = 0; // FUN1 void fun() { this->fun(123); } // FUN2 }; class B : public A { public: virtual void fun(int i) { std::cerr << i << std::endl; } }; int main(int,char**) { B b; b.fun(); } Why can't I call FUN2 on derived class? g++ gives an error: main.cpp:19:8: error: no matching function for call to ‘B::fun()’ EDIT: note

Kotlin functional interfaces java compatiblity

时光毁灭记忆、已成空白 提交于 2019-12-19 18:16:19
问题 I work on an application in kotlin, but need to have a good java support. The problem I found are kotlin's functions. this is what I used to do fun test(loader: (String) -> Int) but this will compile into a Function1 from kotlin library and since I don't have kotlin library directly included in the jar because of jar size, it makes it harder for java developers because they have to download the kotlin library to be able to use this method. I tried to use Supplier or Function interface from

Where to put common interface methods when dealing with partial classes, inheritance, and Visual Studio Generated Code

℡╲_俬逩灬. 提交于 2019-12-19 11:44:36
问题 Consider this situation: We have two classes generated by Visual Studio, for example Typed Dataset Rows. These classes derive from a common base class which we cannot change. We cannot change the class these child classes derive from, but they are generated as partial classes so we can extend them. Now we decide to implement an interface for these two classes which define some common methods, but the methods are going to be implemented exactly the same way in both classes. Where is the best

JAVA - Abstraction

孤人 提交于 2019-12-19 10:52:41
问题 I am little confused about abstraction in java. I have checked many pages stating that abstraction is data hiding(Hiding the implementation). What I understand about abstraction is it is 'partial implementation'. Just define what you are going to need in an abstract class/interface and afterwards extend/implement them and add your own functionality. What I don't understand is how this is a data hiding? You are going to get access to the code once you implement the class/interface and you will

JAVA - Abstraction

筅森魡賤 提交于 2019-12-19 10:52:09
问题 I am little confused about abstraction in java. I have checked many pages stating that abstraction is data hiding(Hiding the implementation). What I understand about abstraction is it is 'partial implementation'. Just define what you are going to need in an abstract class/interface and afterwards extend/implement them and add your own functionality. What I don't understand is how this is a data hiding? You are going to get access to the code once you implement the class/interface and you will

windows.form c# moving between forms

和自甴很熟 提交于 2019-12-19 10:44:13
问题 I am designing an installer interface for a already written program. It is my first windows.form. I see three approaches to solving my "problem" of needing multiple "screens". I can add all the labels/buttons/interface, and then hide/show them at events. Or I can close and open a new windows? Or do I somehow load my next form into the window frame (sortv like an iFrame approach)? Can somehow help explain how to do this? Thanks! 回答1: Though there is nothing stopping you from using any of the