IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesDelphi  Print This     

Inheritance

The concept of a class makes it possible to define subclasses that share some or all of the main class characteristics. This is called inheritance. Inheritance also allows you to reuse code more efficiently. In a class tree, inheritance is used to design classes vertically. (You can use Interfaces to design classes horizontally within a class tree.) With inheritance, you are defining an "is-a" relationship (i.e. a chow is-a dog). Analysts using UML call this generalization where you generalize specific classes into general parent classes.

Delphi:   =class(ParentClass)

In Delphi, you use the class keyword followed by the parent class in parens. If you leave out the parent class, your class inherits from TObject.

Syntax Example:

In the following example, a terminator T-600 is-an android. 

TAndroid = class
end;
 
T-600 = class(TAndroid)
end;




Cross Reference Examples:

ASP Classic:   Not Supported
C#:   : ParentClass

In C#, you use the class keyword followed by the parent class after a colon. If you leave out the parent class, your class inherits from System.Object.

Syntax Example:

In the following example, a terminator T-600 is-an android. 

public class Android
{
}
 
public class T-600 : Android
{
}
C++:   : public ParentClass

In C++ you use the class keyword to signify a class and a colon followed by the parent class name for inheritance.

Syntax Example:

In the following example, a terminator T-600 is-an android. 

class Android {
};
 
class T-600: Public Android {
};
Corel Paradox:   Not Supported

ObjectPAL does not support class creation nor sub-classing (inheritance).

Delphi Prism:   =class(ParentClass)

In Prism, like Delphi, you use the class keyword followed by the parent class in parens. If you leave out the parent class, your class inherits from System.Object.

Syntax Example:

In the following example, a terminator T-600 is-an android. 

Android = public class
end;
 
T-600 = public class(Android)
end;
Java:   extends ParentClass

Simple syntax example of class inheritance.

Syntax Example:

In the following example, a terminator T-600 is-an android. 

public class Android {
}
 
public class T-600 extends Android {
}
JavaScript:   No, but sort of.

JavaScript does not offer a formal inheritance machanism. There are some tricks some developers are fond of.

VB Classic:   No, but see Implements.

VB classic supports only a single "level" of interface inheritance (abstract class to implimentation class). See Implements in VB's help.

VB.Net:   Inherits ParentClass

VB.Net uses the Inherits keyword followed by the parent class name. If you do not include Inherits, your class inherits from System.Object.

Syntax Example:

In the following example, a terminator T-600 is-an android. 

Public Class Android
End Class
 
Public Class T-600
  Inherits Android
End Class




-
   Contact Us!
 
Have a question? Need our services? Contact us now.
--Mike Prestwood

Call: 916-726-5675

email: info@prestwood.com


Go ahead!   Use Us! Call: 916-726-5675 


©1995-2019 Prestwood IT Solutions.   [Security & Privacy]