interface

Does C++ have a static polymorphism implementation of interface that does not use vtable?

Does C++ have a proper implementation of interface that does not use vtable? for example class BaseInterface{ public: virtual void func() const = 0; } class BaseInterfaceImpl:public BaseInterface{ public: void func(){ std::cout<<"called."<<endl; } } BaseInterface* obj = new BaseInterfaceImpl(); obj->func(); the call to func at the ...

Using an interface as a constructor parameter in Java?

How would I be able to accomplish the following: public class testClass implements Interface { public testClass(Interface[] args) { } } So that I could declare Interface testObject = new testClass(new class1(4), new class2(5)); Where class1 and class2 are also classes that implement Interface. Also, once I accomplish th...

How to add member variable to an interface in c#

I know this may be basic but I cannot seem to add a member variable to an interface. I tried inheriting the interface to an abstract class and add member variable to the abstract class but it still does not work. Here is my code: public interface IBase { void AddData(); void DeleteData(); } public abstract class AbstractBase : IBas...

Method name collision in interface implementation - Java

If I have two interfaces , both quite different in their purposes , but with same method signature , how do I make a class implement both without being forced to write a single method that serves for the both the interfaces and writing some convoluted logic in the method implementation that checks for which type of object the call is bei...

Is this a good way to expose generic base class methods through an interface?

I am trying to provide an interface to an abstract generic base class. I want to have a method exposed on the interface that consumes the generic type, but whose implementation is ultimately handled by the classes that inherit from my abstract generic base. However I don't want the subclasses to have to downcast to work with the generi...

creating a shared library from c++ source file

when I tried to create a shared library file using the "cl" command in the vc++ command prompt, it shows a error saying "Can't open include file "jni.h": No such file or directory"... the jni.h is tried to be included in the machine generated header file from java class... i am using this for java navite interface operations... can any o...

Problem with interface implementation in partial classes.

I have a question regarding a problem with L2S, Autogenerated DataContext and the use of Partial Classes. I have abstracted my datacontext and for every table I use, I'm implementing a class with an interface. In the code below you can see I have the Interface and two partial classes. The first class is just there to make sure the class ...

Why would the VB.NET compiler think an interface isn't implemented when it is?

Update I don't think I was clear enough when I originally posted this quesion. Take a look at these screenshots. (Link to bigger screenshot here) Notice the portions I've boxed in red. The class displayed here does implement INotifyPropertyChanged, but the VB compiler seems to think that the PropertyChanged event as declared does no...

Changing property stubs for Interface refactoring

Is it possible to change the stub used to implement interfaces in Visual Studio 2008? For instance, when I choose either Implement interface 'IMyInterface' or Explicitly implement interface 'IMyInterface' Instead of a number of properties that look like this: public string Comment { get { throw n...

Difference between "+" and "-" before function name in Objective-C

Hello Everyone, What is the difference between "+" and "-" before the function name interface declaration in an Objective-C program. Example: - (void)continueSpeaking; + (NSArray *)availableVoices; What's the difference? ...

Interface and partial classes

According to rule SA1201 in StyleCop elements in class must appear in correct order. The order is following: Fields Constructors Finalizers (Destructors) Delegates Events Enums Interfaces Properties Indexers Methods Structs Classes Everything is ok, except of Interfaces part, because Interface can c...

Casting interfaces in java

I had two separate interfaces, one 'MultiLingual' for choosing language of text to return, and second 'Justification' to justify returned text. Now I need to join them, but I'm stuck at 'java.lang.ClassCastException' error. Class Book is not important here. Data.length and FormattedInt.width correspond to the width of the line. The code ...

C++ exceptions binary compatibility

hi. my project uses 2 different C++ compilers, g++ and nvcc (cuda compiler). I have noticed exception thrown from nvcc object files are not caught in g++ object files. are C++ exceptions supposed to be binary compatible in the same machine? what can cause such behavior? try { kernel_= new cuda:: Kernel(); } catch (...) { kernel_= NULL...

More advanced usage of interfaces

To be honest I'm not quite sure if I understand the task myself :) I was told to create class MySimpleIt, that implements Iterator and Iterable and will allow to run the provided test code. Arguments and variables of objects cannot be either Collections or arrays. The code : MySimpleIt msi=new MySimple(10,100, ...

Casting of interfaces

interfaces provide a useful abstraction capability. One can have a class Foo implement some interfaces, say A, B, and C. Some client code may get a reference of type A, others one of type B, etc. each actually the same Foo object but the interface exposing only a narrow subset of the functionality. Of course, evil client code can try to ...

C#: Preferred pattern for functions requiring arguments that implement two interfaces

The argument to my function f() must implement two different interfaces that are not related to each other by inheritance, IFoo and IBar. I know of two different ways of doing this. The first is to declare an empty interface that inherits from both: public interface IFooBar : IFoo, IBar { // nothing to see here } public int f(IFooB...

Java inheritance question

I have an abstract class Airplane, and two classes PassengerAirplane and CargoAirplane, which extend class Airplane. I also have an interface Measurable, and two classes that implement it - People and Containers. So, Airplane can do many things on its own, and there is a method which allows measurable things to be added to the airplane (...

My abstract class implements an interface but doesn't implement some of its methods. How do I make it compile?

interface ICanvasTool { void Motion(Point newLocation); void Tick(); } abstract class CanvasTool_BaseDraw : ICanvasTool { protected abstract void PaintAt(Point location); public override void Motion(Point newLocation) { // implementation } } class CanvasTool_Spray : CanvasTool_BaseDraw { protected a...

What is the best way to provide an AutoMappingOverride for an interface in fluentnhibernate automapper

In my quest for a version-wide database filter for an application, I have written the following code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using FluentNHibernate.Automapping; using FluentNHibernate.Automapping.Alterations; using FluentNHibernate.Mapping; using MvcExtensions.Model; using N...

COM Interface Guid

Hello, I'm not much into COM interfaces, so i have a small question, say I have this code: [Guid("148BD528-A2AB-11CE-B11F-00AA00530503"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface IEnumWorkItems { [PreserveSig()] int Next([In] uint RequestCount, [Out] out System.IntPtr Names, ...