Creating Class Hierarchies

Classes can be related to each other in parent-child class relationships called class hierarchies. Suppose you have an object called Orders that contains overall details about a particular order placed for products, and you also have an object called OrderDetails that contains details about a particular individual product within that order. The Orders object can contain multiple OrderDetails objects. To relate the Orders object to the OrderDetails object, place a declaration of the child class in the General Declarations section of the Orders object, such as shown here.

Public ItemDetails As OrderDetails

You then use the Set statement to instantiate the OrderDetails class just as you do for the Orders class.

0 0

Post a comment