English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2007-02-13 15:45:31 · 5 answers · asked by Rajni 2 in Computers & Internet Programming & Design

5 answers

Interface is the mechanism through which (all the functions) we can expose the functionalities of a COM object.

An Interface is a named table of function pointers.
An Interface is neither a class nor a COM component.
COM clients only interact with pointers to interface.
COM components can implement multiple interfaces.
Interfaces are strongly typed.

IUnKnown:
IUnKnown interface is the base interface of every other COM interface. IUnKnown Interface is the interface from which all other interfaces are derived.
functionalities:
1. Object life-span management AddRef & Release
2. Query Interface (Discovery Mechanism) based on discovers the server.

IUnKnown
{
AddRef(...)=0
Release(...)=0
Query Interface(...)=0
}

2007-02-13 22:42:02 · answer #1 · answered by Rishi 3 · 0 0

An interface is known as a "contract" in OO programming terms.

Basically stated, an interface is used to define what class/object must provide in it's implementation (assuming that class is implenting that interface). Note, an interface cannot provide implementation (meaning only method signatures are provided, but no actual code is provided inside the method).

typically, an interface name is denoted by an "I" in front of the name (e.g. IUnknown)

Let's assume C# is your language, and look at some crude code snippets. Starting with a custom interface:

public interface IMyInterface {
void DoSomeWork(string value1, int value2);
int ReturnSomeValue();
}

Notice that the above methods do not have any code in them (no {} braces with code imbetween). The interface is defining only the method signatures (method names, parameters and return types).

Now lets assume you create a class that implements your interface:

public MyClass : IMyInterface {
void DoSomeWork(string value1, int value2) {
// provide your code implementation in here
// no return value, as dictated in the interface contract
}
int ReturnSomeValue() {
int i = 1000;
return i; // note an int is returned, as required
}
}

Notice that when you implement an interface, your class method signatures & return types will need to match the definition provided in the interface that you are implementing. To implement an interface means that your class will support all the defined methods etc that are in the interface (or contract). You cannot implement only a few of them, it is all or nothing. Additional overloaded methods can be provided however, which can then differ somewhat, depending on your needs.

Also note, multiple interfaces can be implemented (depending on what language we are talking about, I am using C# as an example).


IUnknown is an interface that was introduced in COM, which enables objects to query another objects interface at runtime (discovery), and reference/de-reference to that object.

2007-02-13 16:22:15 · answer #2 · answered by cmdrgordan 1 · 1 0

---------------------
Interface
---------------------
Interface may refer to:

* Linguistics: Interfaces are individual components of grammar which do not function in isolation. Rules of one compoment can depend on or affect those in another component.

In computer science:

* Interface (computer science), a property of a software component
* Interface (Java), an abstract type which is used to specify an interface that classes must implement
* Network interface, a point of interconnection between a terminal and a network or between two networks
* User interface, the aggregate of means by which people interact with a machine, device, computer program, or other complex tool

In other fields:

* Interface (chemistry), a surface forming a boundary between two phases
* Interface (music group), an electronic music artist based in New York
* Interface (novel), a 1994 novel by Neal Stephenson and George Jewsbury
* "Interface" (TNG episode), a seventh season episode of Star Trek: The Next Generation
* Interface Inc., a carpet company focused on environmental sustainability
* Physical interface, a device for joining electric circuits together

-------------------
IUnknown:
-------------------
The published COM specification mandates that COM objects must minimally implement the IUnknown interface. This interface comprises three functions - QueryInterface, AddRef and Release.

* QueryInterface is used to obtain a pointer to another interface, given a GUID that uniquely identifies that interface (commonly known as an IID). If the COM object does not implement that interface, an error is returned instead.
* AddRef is used by clients to indicate that a COM object is being referenced. This is necessary to ensure that a COM object is not disposed prematurely
* Release is used by clients to indicate that they have finished using the COM object. An unreferenced COM object may be safely disposed.


interface IUnknown
{
virtual ULONG AddRef(void) = 0;
virtual HRESULT QueryInterface(REFIID riid, void **ppvObject) = 0;
virtual ULONG Release(void) = 0;
};


The IUnknown interface is defined as a GUID with the value of {00000000-0000-0000-C0000-00000000046}.

Miscellanea

* IUnknown as serves as the base for Core Foundation's CFPlugIn framework

2007-02-13 15:52:15 · answer #3 · answered by cool _ sim 2 · 1 0

Interface refers to the total layout of the software/program.

2007-02-13 17:26:47 · answer #4 · answered by as n 2 · 0 0

idk either lol
sorry
:)p

2007-02-13 15:51:01 · answer #5 · answered by Anonymous · 0 1

fedest.com, questions and answers