www.digitalmars.com         C & C++   DMDScript  

D - Interfaces

reply Juarez Rudsatz <juarez nowhere.com> writes:
Can I override implementation of interfaces in inherited classes ?


interface xyz
{
    	void doSomething();
}

class abc: xyz
{
    	void doSomething()
    	{
    	    	// do something
    	}
}

class ijk : abc
{
    	override void doSomething()
    	{
    	    	super();
    	    	// do more things
    	}
}


Juarez Rudsatz
Jul 16 2002
parent reply "Walter" <walter digitalmars.com> writes:
Yes, that should work. -Walter

"Juarez Rudsatz" <juarez nowhere.com> wrote in message
news:Xns924DBBD86640Ajuarezcom 63.105.9.61...
 Can I override implementation of interfaces in inherited classes ?


 interface xyz
 {
     void doSomething();
 }

 class abc: xyz
 {
     void doSomething()
     {
         // do something
     }
 }

 class ijk : abc
 {
     override void doSomething()
     {
         super();
         // do more things
     }
 }


 Juarez Rudsatz

Jul 16 2002
parent reply Juarez Rudsatz <juarez nowhere.com> writes:
This is powerfull.
Even besser then Delphi Object Pascal Implementation.

"Walter" <walter digitalmars.com> wrote in news:ah2n8m$3092$1
 digitaldaemon.com:

 Yes, that should work. -Walter
 
 "Juarez Rudsatz" <juarez nowhere.com> wrote in message
 news:Xns924DBBD86640Ajuarezcom 63.105.9.61...
 Can I override implementation of interfaces in inherited classes ?


 interface xyz
 {
     void doSomething();
 }

 class abc: xyz
 {
     void doSomething()
     {
         // do something
     }
 }

 class ijk : abc
 {
     override void doSomething()
     {
         super();
         // do more things
     }
 }


 Juarez Rudsatz


Jul 17 2002
parent reply "OddesE" <OddesE_XYZ hotmail.com> writes:
I think Delphi, as well as C++ and Java all
allow this.

By the way, shouldn't it be this:

class abc: Object, xyz  // Inherit from Object
{
    void doSomething()
    {
        // do something
    }
}

Or is Object automatically assumed as ancestor
when the first 'class' in the inheritance list
is in fact an interface?


--
Stijn
OddesE_XYZ hotmail.com
http://OddesE.cjb.net
_________________________________________________
Remove _XYZ from my address when replying by mail
Jul 19 2002
parent reply Juarez Rudsatz <juarez nowhere.com> writes:
Delphi, don't allow inherited interfaces be overrided.
I do not know how Java does...

"OddesE" <OddesE_XYZ hotmail.com> wrote in news:ah9629$2ari$1
 digitaldaemon.com:

 I think Delphi, as well as C++ and Java all
 allow this.
 
 By the way, shouldn't it be this:
 
 class abc: Object, xyz  // Inherit from Object
 {
     void doSomething()
     {
         // do something
     }
 }

Jul 19 2002
parent "OddesE" <OddesE_XYZ hotmail.com> writes:
"Juarez Rudsatz" <juarez nowhere.com> wrote in message
news:Xns92508BEABA330juarezcom 63.105.9.61...
 Delphi, don't allow inherited interfaces be overrided.
 I do not know how Java does...

I thought it does as long as the implementing method is defined as public or protected? I can hardly imagine this would not be possible! -- Stijn OddesE_XYZ hotmail.com http://OddesE.cjb.net _________________________________________________ Remove _XYZ from my address when replying by mail
Jul 19 2002