spacer
Yehuda Shiran June 5, 2002
Writing a Classic Base Class
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?

A base class in JScript .NET is like any other classes. You cannot tell a base class from a class that is not extended by other classes. Here is the Employee class, which we can use as a base class for other classes, such as the Manager class (not shown here):

  class Employee{
    var name : String;
    var address : String;
  
    function Employee(empName : String){
      this.name = empName;
    }
 
    function printMailingLabel() {
      print(name);
      print(address);
    }
  }
Let's create an instance of the Employee class, and set its name and address:

  var Bob : Employee = new Employee("Bob Smith");
  Bob.address = "2010 University Avenue, Palo Alto, CA 94301";
The command Bob.printMailingLabel() will yield the following output:

  Bob Smith
  2010 University Avenue, Palo Alto, CA 94301
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 >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
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