Please enable JavaScript to view this site.

DAQFactory User's Guide

Navigation: 5 Sequences & Scripting > 5.20 Object Oriented Programming

5.20.5 Inheritance

Scroll Prev Top Next More

You can create what are called derived classes that inherit the features of the parent class.  So, if you have the class Person like we created above, and want to create a new class that has all the features of Person, but also includes phone numbers you could do:

 

class PersonPhone parent Person

  local string phone

endclass

Now, if you create an object of type PersonPhone, your object will have the member variables name, address, zip and phone.  This becomes much more powerful when we start adding member functions.

You can use the IsKindOf() global function to determine if an object is a certain class or is derived from a certain class:

IsKindOf(object reference, class type): returns 1 if the specified object reference is a particular class, or derived from a particular class.  So:

 

global obPer = new(Person)
global obPerPh = new(PersonPhone)
? isKindOf(obPer, "Person")   // prints 1
? isKindOf(obPer, "PersonPhone") // prints 0
? isKindOf(obPerPh, "Person") // prints 1 since PersonPhone has Person as a parent class
? isKindOf(obPerPh, "PersonPhone") // prints 1