spacer
Yehuda Shiran June 9, 2002
Multiple Inheritance of Interfaces
Tips: June 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

Let's implement the following two interfaces:

  interface FirstInter{
    function printSomething();
  }

  interface SecondInter{
    function printSomething();
  }
by the myClass class. It implements both of these interfaces, providing the body of the printSomething() function:

  class myClass implements FirstInter, SecondInter {
    function printSomething() {
      print("This is something else");
    }
  }
Let's create a new instance of myClass:

  var demo : myClass = new myClass();
Let's define two variables as having the types of the interfaces above, and assign them the demo instance above:

var inter1 : FirstInter = demo;
var inter2 : SecondInter = demo;
Now all three variables (demo, inter1, inter2) share the same implementation of printSomething(), because they all reference the same instance, demo. The following code:

  demo.printSomething();
  inter1.printSomething();
  inter2.printSomething();
yields three identical lines:

  This is something else
  This is something else
  This is something else
To learn more about JScript .NET, go to Column 110, JScript .NET, Part IV: Inheritance.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Creating a Banking Application Deposit Script · Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business