- The Class Hierarchy
- Creating a New Class
- Declaration and Instantiation
- Constructors and Destructors
- Garbage Collection
- Object Operators
- Adding and Overriding Methods
- Calling the Overridden Method
- Access Scope: Public, Private, Protected
- Setting Properties with Methods
- Default and Optional Parameters
- Declaring Variables Static and Const
- Revisiting the StringParser Module
- Example: Creating a Properties Class
- Data-Oriented Classes and Visual Basic Data Types
- Advanced Techniques
Now it's time to introduce some more operators that are used with classes. I've already introduced New. Two others are Isa and Is.
Isa is used to determine whether an object belongs to a class:
Dim t,u as Boolean t = (a Isa Alpha) // t is True u = (b Isa Alpha) // u is True t = (a Isa Beta) // t is False u = (b Isa Beta) // u is True
This is an example of the most basic feature of inheritance. A subclass is a member of the superclass, but the superclass is not a member of the subclass.
The related Is operator tests to see if one object is the same object as another one.
Dim t as Boolean t = (a Is b) // t is False
Note that even though a and b both have the same values, they are different objects because they were both instantiated independently. Here's an example of when this test would return True:
Dim a,b as Alpha Dim t as Boolean a = new Alpha("Woohoo!") b = a t = (a is b) // t is True
Because b is a reference to a, it is considered the same object. In other words, both a and b point to the same location in memory. They do not simply share an equivalent value; they are, in fact, the very same object.