What is an Interface

  • Thread starter Thread starter SamSpade
  • Start date Start date
S

SamSpade

I Picture an Interface as a list of references to methods and properties.
It's nothing except a spec. until it is implemented.

if that is so what is "components"?
Private components As System.ComponentModel.IContainer



If it's an inteface where is the implementation?
 
SamSpade said:
I Picture an Interface as a list of references to methods and
properties. It's nothing except a spec. until it is implemented.

Right. Also often defined as a "contract".
if that is so what is "components"?
Private components As System.ComponentModel.IContainer



If it's an inteface where is the implementation?

The implementation is done in the object (or in the class) assigned to the
variable.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
If it's an inteface where is the implementation?
The implementation is done in the object (or in the class) assigned to the
variable.
I didn't think about the base class. That must be where!

Thanks
 
Public Class Mother

End Class
''''''''''''''''''''''
Public Class Son
Inherits Mother

End Class

'''''''''''''''''''''''''''''''''''''''''''''

Dim x As Mother
x=New Son()

As you see, I have set the variable of type Mother with the reference to an
instance of the type Son(derived from Mother). Welcome to the universe of
the polymorphism. :-))

So, the field "components" is of type IContainer, but points to an instance
of a class(that has the implementation for IContainer interface).
In your form, look for the line of code where the field "components" gets
its value. For sure you will find something different from IContainer.

Ernest
 
* " SamSpade said:
I Picture an Interface as a list of references to methods and properties.
It's nothing except a spec. until it is implemented.

if that is so what is "components"?
Private components As System.ComponentModel.IContainer

This variable can hold references to objects of type 'IContainer' and
all of its subtypes. Subtypes of 'IContainer' are of type 'IContainer'
and consequently can be assigned to the variable. 'IContainer' is an
interface, so you cannot instantiate it directly, but you can
instantiate a class that implements the interface and assign it to the
variable.
If it's an inteface where is the implementation?

In a class that implements the interface, for example:

\\\
Public Class Foo
Implements IContainer
 
Back
Top